@@ -458,9 +458,9 class ApplicationController < ActionController::Base | |||
|
458 | 458 | # Returns the API key present in the request |
|
459 | 459 | def api_key_from_request |
|
460 | 460 | if params[:key].present? |
|
461 | params[:key] | |
|
461 | params[:key].to_s | |
|
462 | 462 | elsif request.headers["X-Redmine-API-Key"].present? |
|
463 | request.headers["X-Redmine-API-Key"] | |
|
463 | request.headers["X-Redmine-API-Key"].to_s | |
|
464 | 464 | end |
|
465 | 465 | end |
|
466 | 466 |
@@ -130,8 +130,11 class User < Principal | |||
|
130 | 130 | |
|
131 | 131 | # Returns the user that matches provided login and password, or nil |
|
132 | 132 | def self.try_to_login(login, password) |
|
133 | login = login.to_s | |
|
134 | password = password.to_s | |
|
135 | ||
|
133 | 136 | # Make sure no one can sign in with an empty password |
|
134 |
return nil if password. |
|
|
137 | return nil if password.empty? | |
|
135 | 138 | user = find_by_login(login) |
|
136 | 139 | if user |
|
137 | 140 | # user is already in local database |
@@ -164,7 +167,7 class User < Principal | |||
|
164 | 167 | |
|
165 | 168 | # Returns the user who matches the given autologin +key+ or nil |
|
166 | 169 | def self.try_to_autologin(key) |
|
167 | tokens = Token.find_all_by_action_and_value('autologin', key) | |
|
170 | tokens = Token.find_all_by_action_and_value('autologin', key.to_s) | |
|
168 | 171 | # Make sure there's only 1 token that matches the key |
|
169 | 172 | if tokens.size == 1 |
|
170 | 173 | token = tokens.first |
@@ -338,12 +341,12 class User < Principal | |||
|
338 | 341 | end |
|
339 | 342 | |
|
340 | 343 | def self.find_by_rss_key(key) |
|
341 | token = Token.find_by_value(key) | |
|
344 | token = Token.find_by_action_and_value('feeds', key.to_s) | |
|
342 | 345 | token && token.user.active? ? token.user : nil |
|
343 | 346 | end |
|
344 | 347 | |
|
345 | 348 | def self.find_by_api_key(key) |
|
346 | token = Token.find_by_action_and_value('api', key) | |
|
349 | token = Token.find_by_action_and_value('api', key.to_s) | |
|
347 | 350 | token && token.user.active? ? token.user : nil |
|
348 | 351 | end |
|
349 | 352 |
General Comments 0
You need to be logged in to leave comments.
Login now