How to make auth0 users to pass @login_required decorator in Django?

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?

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

Many thanks,

Andy

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.

1 Like

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

Cheers,

Andy

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