Improved error handling.
This commit is contained in:
parent
7f7312129c
commit
d2b1e69326
4 changed files with 15 additions and 16 deletions
|
@ -1,16 +1,14 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
module Auth::Developer
|
||||
def self.check( _username, password, _config, user )
|
||||
def self.check(username, password, _config, user)
|
||||
|
||||
# development systems
|
||||
if Setting.get('developer_mode') == true
|
||||
if password == 'test'
|
||||
Rails.logger.info "System in developer mode, authentication for user #{user.login} ok."
|
||||
return user
|
||||
end
|
||||
end
|
||||
|
||||
false
|
||||
return false if !username
|
||||
return false if !user
|
||||
return false if Setting.get('developer_mode') != true
|
||||
return false if password != 'test'
|
||||
Rails.logger.info "System in developer mode, authentication for user #{user.login} ok."
|
||||
user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
module Auth::Internal
|
||||
def self.check( _username, password, _config, user )
|
||||
def self.check(username, password, _config, user)
|
||||
|
||||
# return if no user exists
|
||||
return nil if !user
|
||||
return false if !username
|
||||
return false if !user
|
||||
|
||||
# sha auth check
|
||||
if user.password =~ /^\{sha2\}/
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'net/ldap'
|
||||
|
||||
module Auth::Ldap
|
||||
def self.check( username, password, config, user )
|
||||
def self.check(username, password, config, user)
|
||||
|
||||
scope = Net::LDAP::SearchScope_WholeSubtree
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'import/otrs'
|
||||
|
||||
module Auth::Otrs
|
||||
def self.check( username, password, config, user )
|
||||
def self.check(username, password, config, user)
|
||||
|
||||
endpoint = Setting.get('import_otrs_endpoint')
|
||||
return false if !endpoint
|
||||
|
@ -11,17 +11,17 @@ module Auth::Otrs
|
|||
return false if endpoint == 'http://otrs_host/otrs'
|
||||
|
||||
# connect to OTRS
|
||||
result = Import::OTRS.auth( username, password )
|
||||
result = Import::OTRS.auth(username, password)
|
||||
return false if !result
|
||||
return false if !result['groups_ro']
|
||||
return false if !result['groups_rw']
|
||||
return false if !result['user']
|
||||
|
||||
user = User.where( login: result['user']['UserLogin'], active: true ).first
|
||||
user = User.where(login: result['user']['UserLogin'], active: true).first
|
||||
return false if !user
|
||||
|
||||
# sync / check permissions
|
||||
Import::OTRS.permission_sync( user, result, config )
|
||||
Import::OTRS.permission_sync(user, result, config)
|
||||
|
||||
user
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue