<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def permission_required(perm, login_url=None):
 """Replacement for django.contrib.auth.decorators.permission_required that returns 403 Forbidden if the user is already logged in. """


    return user_passes_test(lambda u: u.has_perm(perm), login_url=login_url)