Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
AuthControllerConfig.php
Go to the documentation of this file.
1<?php
2
4
6use Ubiquity\utils\base\UConfigFile;
7
16abstract class AuthControllerConfig extends AuthController {
17
18 protected array $config;
19
20 public function initialize(){
21 $this->_init();
22 parent::initialize();
23 }
24
25 public function _init(){
26 $file=new UConfigFile($this->getConfigFilename());
27 $this->config=$file->load();
28 }
29
30 abstract protected function getConfigFilename():string;
31
32 protected function useAjax():bool{
33 return $this->config['useAjax']??true;
34 }
35
36 protected function attemptsNumber() {
37 return $this->config['attemptsNumber']??null;
38 }
39
40 public function _getUserSessionKey(): string {
41 return $this->config['userSessionKey']??'activeUser';
42 }
43
44 public function attemptsTimeout():int{
45 return $this->config['attemptsTimeout']??(3*60);
46 }
47
48 public function _displayInfoAsString():bool{
49 return $this->config['displayInfoAsString']??false;
50 }
51
52 public function _getLoginInputName():string{
53 return $this->config['loginInputName']??'email';
54 }
55
56 public function loginLabel():string{
57 return $this->config['loginLabel']??\ucfirst($this->_getLoginInputName());
58 }
59
60 public function _getPasswordInputName():string{
61 return $this->config['passwordInputName']??'password';
62 }
63
64 protected function passwordLabel(): string {
65 return $this->config['passwordLabel']??\ucfirst ( $this->_getPasswordInputName () );
66 }
67
68 protected function passwordConfLabel(): string {
69 return $this->config['passwordConfLabel']??(\ucfirst ( $this->_getPasswordInputName () ).' confirmation');
70 }
71
72 public function _getBodySelector():string {
73 return $this->config['bodySelector']??'main .container';
74 }
75
76 protected function rememberCaption():string {
77 return $this->config['rememberCaption']??'Remember me';
78 }
79
80 protected function getTokenSize():int{
81 return $this->config['2FA.tokenSize']??6;
82 }
83
84 protected function towFACodePrefix():string{
85 return $this->config['2FA.codePrefix']??'U-';
86 }
87
88 protected function hasAccountCreation():bool{
89 return $this->config['hasAccountCreation']??false;
90 }
91
92 protected function hasAccountRecovery():bool{
93 return $this->config['hasAccountRecovery']??false;
94 }
95
96 protected function recoveryAccountCaption():string{
97 return $this->config['recoveryAccountCaption']??'Forgot your password?';
98 }
99
100 public static function init(?string $name=null,?array $config=null){
101 $config??=[
102 'attempsNumber'=>null,
103 'userSessionKey'=>'activeUser',
104 'useAjax'=>true,
105 'attemptsTimeout'=>3*60,
106 'displayInfoAsString'=>false,
107 'loginInputName'=>'email',
108 'loginLabel'=>'Email',
109 'passwordInputName'=>'password',
110 'passwordLabel'=>'Password',
111 'passwordConfLabel'=>'Password confirmation',
112 'rememberCaption'=>'Remember me',
113 'bodySelector'=>'main .container',
114 '2FA.tokenSize'=>6,
115 '2FA.codePrefix'=>'U-',
116 'hasAccountCreation'=>false,
117 'hasAccountRecovery'=>false,
118 'recoveryAccountCaption'=>'Forgot your password?'
119
120 ];
121 $name??=\lcfirst(ClassUtils::getClassSimpleName(static::class));
122 $file=new UConfigFile($name);
123 $file->setData($config);
124 $file->save();
125 }
126
127}
128
Manipulates class and namespace names Ubiquity\cache$ClassUtils This class is part of Ubiquity.
Ubiquity\controllers\auth$AuthControllerConfig This class is part of Ubiquity.
attemptsNumber()
To override Returns int the maximum number of allowed login attempts.
static init(?string $name=null,?array $config=null)
_displayInfoAsString()
Override to define if user info is displayed as string.
getTokenSize()
To override Returns the default size for generated tokens.
recoveryAccountCaption()
Returns the recovery account link caption.
initialize()
{{Method called before each action Can be override in derived class.}\Ubiquity\controllers\Controller...
_getUserSessionKey()
To override for defining user session key, default : "activeUser".
towFACodePrefix()
Returns the code prefix (which should not be entered by the user).