Merged r9798 to r9801 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9803 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
69709a2513
commit
fe1a152e02
|
@ -458,9 +458,9 @@ class ApplicationController < ActionController::Base
|
||||||
# Returns the API key present in the request
|
# Returns the API key present in the request
|
||||||
def api_key_from_request
|
def api_key_from_request
|
||||||
if params[:key].present?
|
if params[:key].present?
|
||||||
params[:key]
|
params[:key].to_s
|
||||||
elsif request.headers["X-Redmine-API-Key"].present?
|
elsif request.headers["X-Redmine-API-Key"].present?
|
||||||
request.headers["X-Redmine-API-Key"]
|
request.headers["X-Redmine-API-Key"].to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -130,8 +130,11 @@ class User < Principal
|
||||||
|
|
||||||
# Returns the user that matches provided login and password, or nil
|
# Returns the user that matches provided login and password, or nil
|
||||||
def self.try_to_login(login, password)
|
def self.try_to_login(login, password)
|
||||||
|
login = login.to_s
|
||||||
|
password = password.to_s
|
||||||
|
|
||||||
# Make sure no one can sign in with an empty password
|
# Make sure no one can sign in with an empty password
|
||||||
return nil if password.to_s.empty?
|
return nil if password.empty?
|
||||||
user = find_by_login(login)
|
user = find_by_login(login)
|
||||||
if user
|
if user
|
||||||
# user is already in local database
|
# user is already in local database
|
||||||
|
@ -164,7 +167,7 @@ class User < Principal
|
||||||
|
|
||||||
# Returns the user who matches the given autologin +key+ or nil
|
# Returns the user who matches the given autologin +key+ or nil
|
||||||
def self.try_to_autologin(key)
|
def self.try_to_autologin(key)
|
||||||
tokens = Token.find_all_by_action_and_value('autologin', key)
|
tokens = Token.find_all_by_action_and_value('autologin', key.to_s)
|
||||||
# Make sure there's only 1 token that matches the key
|
# Make sure there's only 1 token that matches the key
|
||||||
if tokens.size == 1
|
if tokens.size == 1
|
||||||
token = tokens.first
|
token = tokens.first
|
||||||
|
@ -338,12 +341,12 @@ class User < Principal
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_by_rss_key(key)
|
def self.find_by_rss_key(key)
|
||||||
token = Token.find_by_value(key)
|
token = Token.find_by_action_and_value('feeds', key.to_s)
|
||||||
token && token.user.active? ? token.user : nil
|
token && token.user.active? ? token.user : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_by_api_key(key)
|
def self.find_by_api_key(key)
|
||||||
token = Token.find_by_action_and_value('api', key)
|
token = Token.find_by_action_and_value('api', key.to_s)
|
||||||
token && token.user.active? ? token.user : nil
|
token && token.user.active? ? token.user : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue