#2203: Try to use basic password also as a token when accessing a token-enabled endpoint

This commit is contained in:
Jyri-Petteri Paloposki 2019-05-04 23:13:28 +03:00
parent 996395cc80
commit 3186683cd0

View file

@ -72,10 +72,17 @@ module LoginSystem
def login_or_feed_token_required
if ['rss', 'atom', 'txt', 'ics', 'xml'].include?(params[:format])
# Login based on the token GET parameter
if user = User.where(:token => params[:token]).first
set_current_user(user)
return true
end
# Allow also login based on auth data
auth = get_basic_auth_data
if user = User.where(:login => auth[:user], :token => auth[:pass]).first
set_current_user(user)
return true
end
end
login_required
end