From e9d0b5a1ff131656ebde9924dc34d056d785b9cd Mon Sep 17 00:00:00 2001 From: Martijn Stegeman Date: Sat, 19 Dec 2020 11:12:56 +0100 Subject: [PATCH] fix token auth --- app/helpers/authentication_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/authentication_helper.rb b/app/helpers/authentication_helper.rb index a1e28f98..740b6ea6 100644 --- a/app/helpers/authentication_helper.rb +++ b/app/helpers/authentication_helper.rb @@ -15,7 +15,11 @@ def current_user private def load_current_user - if authenticated? && login = Login.where(login: (request.session['cas']['user']).downcase).first + if request.session['token'].present? + if user = User.where(token: request.session['token']).first + @current_user = user + end + elsif request.session['cas'].present? && login = Login.where(login: (request.session['cas']['user']).downcase).first @current_user = login.user else # use an empty user object in case of no login