-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Save last login method in a cookie #12286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Initial attempt to save the "last login method" into a cookie so we can show a visual label next to the button to login. This is only the backend part. We need to write some code in the template to use this value next. I'm not happy with the implementation because looks pretty complex. I didn't find an easier way to do it and I'm open for suggestions. Required by readthedocs/ext-theme#421
Alternatively, we could use basic events on elements in the login UI to set a cookie from the client side. If the user last clicked on the GitHub button or Email tab, we store that and either consume it at the backend and use it as context data into the view, or it's also possible to do this all on the front end side but it will be a fair amount of JS. |
What about subscribing to all the social buttons and email's submit button and use using |
Seems like hooking into allauth is probably the right place here? Doing middleware feels really heavy. I looked briefly at the docs and couldn't find an obvious place. @stsewd do you know if there's a good spot to hook here? |
Is this different than what I suggested? #12286 (comment) Seems like you're suggesting the same thing, I think that's fine yeah. |
Now that I re-read your comment, it seems I'm suggesting the same, yeah haha 😅 I tried
(from https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/set) So, I will need to disable that somehow for developing or add SSL somehow to the local environment. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
…mitos/save-last-login-method
This is now working as I want. We read the cookie set by the front-end and expose 2 variables in the context for the templates:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be fine with this, but still think just having this on the client side with the local storage makes more sense. @agjohnson probably knows better how much work that would be, we are already using bindings to hide content based on conditions.
@stsewd we already discussed this in #12286 (comment) |
Initial attempt to save the "last login method" into a cookie so we can show a visual label next to the button to login.
This is only the backend part. We need to write some code in the template to use this value next.
I'm not happy with the implementation because looks pretty complex. I didn't find an easier way to do it and I'm open for suggestions.
Required by readthedocs/ext-theme#421