mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
#2203: Try to use basic password also as a token when accessing a token-enabled endpoint
This commit is contained in:
parent
996395cc80
commit
3186683cd0
1 changed files with 7 additions and 0 deletions
|
|
@ -72,10 +72,17 @@ module LoginSystem
|
||||||
|
|
||||||
def login_or_feed_token_required
|
def login_or_feed_token_required
|
||||||
if ['rss', 'atom', 'txt', 'ics', 'xml'].include?(params[:format])
|
if ['rss', 'atom', 'txt', 'ics', 'xml'].include?(params[:format])
|
||||||
|
# Login based on the token GET parameter
|
||||||
if user = User.where(:token => params[:token]).first
|
if user = User.where(:token => params[:token]).first
|
||||||
set_current_user(user)
|
set_current_user(user)
|
||||||
return true
|
return true
|
||||||
end
|
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
|
end
|
||||||
login_required
|
login_required
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue