return unless request.post?
self.current_user = User.authenticate(params[:login], params[:password])
- if logged_in? && current_user.active
+ if logged_in?
if params[:remember_me] == '1'
self.current_user.remember_me
cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
self.dashboards.each {|d| d.destroy}
self.active_dashboards.each {|ad| ad.destroy}
end
+
+ def self.find_active_by_login(login)
+ User.find(:first, :conditions => ["login=:login AND active=:active", {:login => login, :active => true}])
+ end
#---------------------------------------------------------------------
#
class DefaultRealm
def authenticate?(username, password)
- user = User.find_by_login(username)
+ user = User.find_active_by_login(username)
if user && user.authenticated?(password)
return user
else
# Fallback to password from Sonar Database
#
def fallback(username, password)
- user = User.find_by_login(username)
+ user = User.find_active_by_login(username)
if user && user.authenticated?(password)
return user
else
else
return nil if !status
# Authenticated
- return syncronize(username, password, details)
+ return synchronize(username, password, details)
end
else
# No authenticator
#
# Authentication in external system was successful - replicate password, details and groups into Sonar
#
- def syncronize(username, password, details)
+ def synchronize(username, password, details)
user = User.find_by_login(username)
if !user
# No such user in Sonar database
user.password_confirmation = password
end
synchronize_groups(user)
+ # A user that is synchronized with an external system is always set to 'active' (see SONAR-3258 for the deactivation concept)
+ user.active=true
# Note that validation disabled
user.save(false)
return user