35 $this->authenticationControllerName = null;
36 if(!$auth_sets)
return true;
38 foreach($auth_sets as $set){
40 $controller_name = null;
41 foreach($set as $name){
42 $authenticated = $this->authenticators[$name]->authenticated;
43 if($authenticated ===
false){
44 $this->
component(
'log')->debug(
'Negative authentication for ' . $name,__FILE__,__LINE__);
47 elseif(!$authenticated){
49 if(!$controller_name) $controller_name = $this->authenticators[$name]->controllerName;
52 if(!$missing)
return true;
53 if(!$best || ($missing < $best)){
55 $this->authenticationControllerName = $controller_name;
58 return $best ? null :
false;
66 return $this->
component(
'event')->trigger(self::EVENT_RIGHT_LEVEL,$this,$right);
75 if(!$level) $level = \Rsi\Str::part($right,self::RIGHT_LEVEL_SEPARATOR,1) ?: self::RIGHT_LEVEL_READ;
76 $right = \Rsi\Str::part($right,self::RIGHT_LEVEL_SEPARATOR);
77 return $right ? $this->
level($right) >= $level :
true;
84 $this->
component(
'event')->trigger(self::EVENT_INVALIDATE,$this);
85 foreach($this->authenticators as $authenticator) $authenticator->invalidate();
86 $this->_id = $this->_record = null;
87 if($this->authorative) $this->session->id = null;
96 return $this->
component(
'event')->trigger(self::EVENT_NAME,$this,$id);
104 return $this->
component(
'event')->trigger(self::EVENT_RECORD,$this,$id);
111 public function id($code){
112 return $this->
component(
'event')->trigger(self::EVENT_ID,$this,$code);
116 if($this->_authenticators === null){
117 $this->_authenticators = [];
118 foreach($this->
config(
'authenticators',[]) as $name => $config){
119 $class_name = \Rsi\Record::get($config,
'className',__CLASS__ .
'\\Authenticator\\' . ucfirst($name));
120 $this->_authenticators[$name] =
new $class_name($this->_fred,$config);
127 if($value != $this->
id){
130 if($this->authorative) $this->session->id = $value;
135 return $this->authorative ? $this->session->id :
$this->_id;
139 if($this->_record === null) $this->_record = $this->
record($this->
id);
146 $this->_files =
new $class_name($this->_fred,$this->
config(
'files',[]) + [
'user' => $this]);
152 return \Rsi\Record::get($this->
record,$key);
155 protected function _set($key,$value){
156 $this->
component(
'event')->trigger(self::EVENT_SET,$this,$key,$value);
160 $this->authorative =
false;
161 $this->_authenticators = null;
config($key, $default=null)
Retrieve a config value.
authorized($right, $level=null)
Check if the authenticated user has a certain right.
$filesClassName
Class name for the file manager.
name($id)
Returns a user friendly name for an user ID.
record($id)
Get the record (data) for a user.
authenticated($auth_sets)
Check if a user is authenticated.
invalidate()
Invalidate the current user.
$_authenticators
Available authentication checks.
$authenticationControllerName
Set if the user has to provide more information for authentication.
const RIGHT_LEVEL_SEPARATOR
Separator between right and level in a single string notation.
const RIGHT_LEVEL_EXECUTE
id($code)
Translate a user code (external ID) to a user ID (internal ID).
level($right)
Get the current user's right level.
component($name)
Get a component (local or default).