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/
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module Auth::Developer
|
module Auth::Developer
|
||||||
def self.check( _username, password, _config, user )
|
def self.check(username, password, _config, user)
|
||||||
|
|
||||||
# development systems
|
# development systems
|
||||||
if Setting.get('developer_mode') == true
|
return false if !username
|
||||||
if password == 'test'
|
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."
|
Rails.logger.info "System in developer mode, authentication for user #{user.login} ok."
|
||||||
return user
|
user
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module Auth::Internal
|
module Auth::Internal
|
||||||
def self.check( _username, password, _config, user )
|
def self.check(username, password, _config, user)
|
||||||
|
|
||||||
# return if no user exists
|
# return if no user exists
|
||||||
return nil if !user
|
return false if !username
|
||||||
|
return false if !user
|
||||||
|
|
||||||
# sha auth check
|
# sha auth check
|
||||||
if user.password =~ /^\{sha2\}/
|
if user.password =~ /^\{sha2\}/
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'net/ldap'
|
require 'net/ldap'
|
||||||
|
|
||||||
module Auth::Ldap
|
module Auth::Ldap
|
||||||
def self.check( username, password, config, user )
|
def self.check(username, password, config, user)
|
||||||
|
|
||||||
scope = Net::LDAP::SearchScope_WholeSubtree
|
scope = Net::LDAP::SearchScope_WholeSubtree
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'import/otrs'
|
require 'import/otrs'
|
||||||
|
|
||||||
module Auth::Otrs
|
module Auth::Otrs
|
||||||
def self.check( username, password, config, user )
|
def self.check(username, password, config, user)
|
||||||
|
|
||||||
endpoint = Setting.get('import_otrs_endpoint')
|
endpoint = Setting.get('import_otrs_endpoint')
|
||||||
return false if !endpoint
|
return false if !endpoint
|
||||||
|
@ -11,17 +11,17 @@ module Auth::Otrs
|
||||||
return false if endpoint == 'http://otrs_host/otrs'
|
return false if endpoint == 'http://otrs_host/otrs'
|
||||||
|
|
||||||
# connect to OTRS
|
# connect to OTRS
|
||||||
result = Import::OTRS.auth( username, password )
|
result = Import::OTRS.auth(username, password)
|
||||||
return false if !result
|
return false if !result
|
||||||
return false if !result['groups_ro']
|
return false if !result['groups_ro']
|
||||||
return false if !result['groups_rw']
|
return false if !result['groups_rw']
|
||||||
return false if !result['user']
|
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
|
return false if !user
|
||||||
|
|
||||||
# sync / check permissions
|
# sync / check permissions
|
||||||
Import::OTRS.permission_sync( user, result, config )
|
Import::OTRS.permission_sync(user, result, config)
|
||||||
|
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue