jarkow
jarkow

Reputation: 113

Remember username after logging out

I want to achieve something similar to what can be found on mobile phones. After pressing the Logout button my app redirects to the lockscreen, which prompts for the user password only. Something like:

Hey, username!
Type your password to access the app again: 

I'm using django.contrib.auth.views

Upvotes: 1

Views: 182

Answers (1)

Łukasz
Łukasz

Reputation: 36231

The easiest solution would be to just before logout save the username to the session (or directly to a cookie) and on rendering the login page prepopulate the username field if present in the session. All of that will require wrapping default view functions and modifying the login template.

Alternative could be to just save the username to the cookie and use bit of JavaScript code to prepopulate username field.

Both options will require some tweaking to your precise situation.

Upvotes: 2

Related Questions