[37553] Make user run through authentication stages after header SSO (#9458)
https://community.openproject.org/wp/37553pull/9475/head
parent
16d1f57857
commit
b7696a6c5c
@ -0,0 +1,30 @@ |
||||
module Accounts::UserLogin |
||||
include ::Accounts::AuthenticationStages |
||||
include ::Accounts::RedirectAfterLogin |
||||
|
||||
def login_user!(user) |
||||
# generate a key and set cookie if autologin |
||||
if Setting.autologin? && (params[:autologin] || session.delete(:autologin_requested)) |
||||
set_autologin_cookie(user) |
||||
end |
||||
|
||||
# Set the logged user, resetting their session |
||||
self.logged_user = user |
||||
|
||||
call_hook(:controller_account_success_authentication_after, user: user) |
||||
|
||||
redirect_after_login(user) |
||||
end |
||||
|
||||
def set_autologin_cookie(user) |
||||
token = Token::AutoLogin.create(user: user) |
||||
cookie_options = { |
||||
value: token.plain_value, |
||||
expires: 1.year.from_now, |
||||
path: OpenProject::Configuration['autologin_cookie_path'], |
||||
secure: OpenProject::Configuration['autologin_cookie_secure'], |
||||
httponly: true |
||||
} |
||||
cookies[OpenProject::Configuration['autologin_cookie_name']] = cookie_options |
||||
end |
||||
end |
Loading…
Reference in new issue