# How to make auth0 users to pass @login\_required decorator in Django?

**URL:** <https://community.auth0.com/t/how-to-make-auth0-users-to-pass-login-required-decorator-in-django/104203>\
**Category:** Get Help\
**Tags:** account-linking, user-management\
**Created:** [April 5, 2023, 7:35pm UTC](https://community.auth0.com/t/how-to-make-auth0-users-to-pass-login-required-decorator-in-django/104203 "2023-04-05T19:35:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fkim11357](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fkim11357/32/45561_2.png) [@fkim11357](https://community.auth0.com/u/fkim11357)\
**Post date:** [April 5, 2023, 7:35pm UTC](https://community.auth0.com/t/how-to-make-auth0-users-to-pass-login-required-decorator-in-django/104203/1 "2023-04-05T19:35:06Z")

</div>

I already have an existing user model in my django app. I don’t want to migrate my users to auth0. I want to keep both ways of logins. However, users access via auth0 can’t pass @login\_required decorator. How to create a login session with auth0 data?

---

<div class="post-metadata">

**Author:** ![andycrellin](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@andycrellin](https://community.auth0.com/u/andycrellin)\
**Post date:** [April 28, 2023, 9:17am UTC](https://community.auth0.com/t/how-to-make-auth0-users-to-pass-login-required-decorator-in-django/104203/3 "2023-04-28T09:17:10Z")

</div>

Hi @fkim11357 I’m having the same issue - did you resolve this?

Many thanks,

Andy

---

<div class="post-metadata">

**Author:** ![fkim11357](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fkim11357/32/45561_2.png) [@fkim11357](https://community.auth0.com/u/fkim11357)\
**Post date:** [April 28, 2023, 3:44pm UTC](https://community.auth0.com/t/how-to-make-auth0-users-to-pass-login-required-decorator-in-django/104203/4 "2023-04-28T15:44:50Z")

</div>

No. @login\_required decorator uses request.user which is always Anonymous when authenticated by auth0. I wrote a small function that gets email from request.session.get(“user”), and then find the user. If the user is new, then create one. Set the “user” in the context before render.

---

<div class="post-metadata">

**Author:** ![andycrellin](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@andycrellin](https://community.auth0.com/u/andycrellin)\
**Post date:** [April 29, 2023, 11:28am UTC](https://community.auth0.com/t/how-to-make-auth0-users-to-pass-login-required-decorator-in-django/104203/5 "2023-04-29T11:28:36Z")

</div>

Thanks for coming back to me - in the end I did exactly the same thing and created my own decorator 🙂

Cheers,

Andy

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 17, 2023, 10:56am UTC](https://community.auth0.com/t/how-to-make-auth0-users-to-pass-login-required-decorator-in-django/104203/6 "2023-05-17T10:56:40Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
