[refs #782] restore login&pass authentication
This commit is contained in:
parent
2bb5d517a2
commit
2f1a21cbdf
|
@ -86,10 +86,12 @@ class User < Avatar
|
|||
class << self
|
||||
def find_for_database_authentication(warden_conditions)
|
||||
conditions = warden_conditions.dup
|
||||
|
||||
login = conditions.delete(:login)
|
||||
pass = conditions.delete(:pass)
|
||||
user = User.where(conditions).where(:authentication_token => login).first ||
|
||||
User.where(conditions).where(["lower(uname) = :value OR lower(email) = :value", { :value => login.downcase}]).first
|
||||
return user if !user.access_locked? and (user.authentication_token == login or user.valid_password?(p))
|
||||
return user if !user.access_locked? and (user.authentication_token == login or user.valid_password?(pass))
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ module Grack
|
|||
return render_not_found if project.blank?
|
||||
|
||||
return ::Rack::Auth::Basic.new(@app) do |u, p|
|
||||
user = User.find_for_database_authentication(:login => u) and
|
||||
user = User.find_for_database_authentication({:login => u, :pass => p}) and
|
||||
ability = ::Ability.new(user) and ability.can?(action, project) # project.members.include?(user)
|
||||
end.call(env) unless project.public? and read? # need auth
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue