lib/auth_lh/authentication.rb in auth-lh-0.3.0 vs lib/auth_lh/authentication.rb in auth-lh-0.3.1
- old
+ new
@@ -24,26 +24,22 @@
def find_external(login)
all_external.find { |x| x.login == login.to_s }
end
def find_current_user(session_token, remote_ip)
- if (session_token.present? && (@session_token != session_token))
- response = AuthLh.get_current_user(session_token, remote_ip)
+ response = AuthLh.get_current_user(session_token, remote_ip)
- if response.nil?
- @cached_logged_user = nil
- @session_token = nil
- @login_error = nil
- else
- @cached_logged_user = response.user
- @session_token = session_token
- @login_error = response.reason
- end
+ if response.nil?
+ logged_user = nil
+ login_error = nil
+ else
+ logged_user = response.user
+ login_error = response.reason
end
- if @cached_logged_user
- user = find_or_create_by(login: @cached_logged_user.login)
- user.auth_user = @cached_logged_user
+ if logged_user
+ user = find_or_create_by(login: logged_user.login)
+ user.auth_user = logged_user
user
else
nil
end
end