js: keep last selected ou on login form (fixes #31329)
This commit is contained in:
parent
eac4437e5c
commit
d856fc07ca
|
@ -265,6 +265,8 @@ class AuthenticationForm(auth_forms.AuthenticationForm):
|
|||
def media(self):
|
||||
media = super(AuthenticationForm, self).media
|
||||
media.add_js(['authentic2/js/js_seconds_until.js'])
|
||||
if app_settings.A2_LOGIN_FORM_OU_SELECTOR:
|
||||
media.add_js(['authentic2/js/ou_selector.js'])
|
||||
return media
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
$(function () {
|
||||
var $ou_selector = $('#id_ou');
|
||||
var cache_key = 'a2_login_ou';
|
||||
var $form = $ou_selector.parents('form');
|
||||
var last_selection = localStorage.getItem(cache_key);
|
||||
if (last_selection) {
|
||||
$ou_selector.val(last_selection);
|
||||
}
|
||||
$form.on('submit', function () {
|
||||
var value = $ou_selector.val();
|
||||
if (value) {
|
||||
localStorage.setItem(cache_key, value);
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue