diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2017-06-07 08:45:34 +0000 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2017-07-03 16:25:10 +0000 |
commit | 5b649ac64dc2a987e2bede544dd13c1fab2d55a4 (patch) | |
tree | f60fc3328d8205cdfd4d296152dae97734c517f9 /app/views/devise | |
parent | c8eef2d2a62f6ac7304c8ab4d50282613e21ec8a (diff) | |
download | gitlab-ce-5b649ac64dc2a987e2bede544dd13c1fab2d55a4.tar.gz |
Implement "remember me" for OAuth-based login.
- Pass a `remember_me` query parameter along with the initial OAuth request, and
pick this parameter up during the omniauth callback from
request.env['omniauth.params']`
- For 2FA-based login, copy the `remember_me` param from `omniauth.params` to
`params`, which the 2FA process will pick up.
- For non-2FA-based login, simply call the `remember_me` devise method to set
the session cookie.
Diffstat (limited to 'app/views/devise')
-rw-r--r-- | app/views/devise/shared/_omniauth_box.html.haml | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/views/devise/shared/_omniauth_box.html.haml b/app/views/devise/shared/_omniauth_box.html.haml index f92f89e73ff..acb38c300b9 100644 --- a/app/views/devise/shared/_omniauth_box.html.haml +++ b/app/views/devise/shared/_omniauth_box.html.haml @@ -6,4 +6,21 @@ - providers.each do |provider| %span.light - has_icon = provider_has_icon?(provider) - = link_to provider_image_tag(provider), omniauth_authorize_path(:user, provider), method: :post, class: (has_icon ? 'oauth-image-link' : 'btn') + = link_to provider_image_tag(provider), omniauth_authorize_path(:user, provider), method: :post, class: 'oauth-login' + (has_icon ? ' oauth-image-link' : ' btn') + %fieldset + = check_box_tag :remember_me + = label_tag :remember_me, "Remember Me" + +:javascript + $("#remember_me").click(function(event){ + var rememberMe = $(event.target).is(":checked"); + $(".oauth-login").each(function(i, element) { + var href = $(element).attr('href'); + + if (rememberMe) { + $(element).attr('href', href + '?remember_me=1'); + } else { + $(element).attr('href', href.replace('?remember_me=1', '')); + } + }); + }); |