user = User.new(params[:user])
user.external_identity = user.login
user.external_identity_provider = 'sonarqube'
+ user.user_local = true
default_group_name=java_facade.getSettings().getString('sonar.defaultGroup')
default_group=Group.find_by_name(default_group_name)
user.groups<<default_group if default_group
# HACK HACK HACK -- how to do attr_accessible from here?
# prevents a user from submitting a crafted form that bypasses activation
# anything else you want your user to change should be added here.
- attr_accessible :login, :email, :name, :password, :password_confirmation, :external_identity, :external_identity_provider
- attr_accessor :token_authenticated, :external_identity, :external_identity_provider
+ attr_accessible :login, :email, :name, :password, :password_confirmation, :external_identity, :external_identity_provider, :user_local
+ attr_accessor :token_authenticated, :external_identity, :external_identity_provider, :user_local
####
# As now dates are saved in long they should be no more automatically managed by Rails
write_attribute :external_identity_provider, value
end
+ def user_local=(value)
+ write_attribute :user_local, value
+ end
+
# SCM accounts should also contain login and email
def full_scm_accounts
new_scm_accounts = self.scm_accounts.split(/\r?\n/).reject { |c| c.empty? } if self.scm_accounts
end
def authenticate?(username, password, servlet_request)
- local_users = Api::Utils.java_facade.getSettings().getStringArray('sonar.security.localUsers')
- if local_users.include? username
+ countUserLocal = User.count('id', :conditions => ['login=? and user_local=?', username, true])
+ if countUserLocal > 0
local_auth(username, password)
else
auth(username, password, servlet_request)
user = User.new(:login => username, :name => username, :email => '', :created_at => now, :updated_at => now)
user.external_identity = username
user.external_identity_provider = 'sonarqube'
+ user.user_local = false
if details
user.name = details.getName()