Passed
Push — master ( 0ed261...e52b37 )
by Jean-Christophe
17:09
created

AuthControllerVariablesTrait::towFACodePrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Ubiquity\controllers\auth;
4
5
use Ubiquity\utils\flash\FlashMessage;
6
7
trait AuthControllerVariablesTrait {
8
9
	/**
10
	 * Override for modifying the noAccess message
11
	 *
12
	 * @param FlashMessage $fMessage
13
	 */
14 1
	protected function noAccessMessage(FlashMessage $fMessage) {
15 1
	}
16
17
	/**
18
	 * Override for modifying attempts message
19
	 * You can use {_timer} and {_attemptsCount} variables in message content
20
	 *
21
	 * @param FlashMessage $fMessage
22
	 * @param int $attempsCount
23
	 */
24
	protected function attemptsNumberMessage(FlashMessage $fMessage, $attempsCount) {
25
	}
26
27
	/**
28
	 * To override for modifying the bad login message
29
	 *
30
	 * @param FlashMessage $fMessage
31
	 */
32 1
	protected function badLoginMessage(FlashMessage $fMessage) {
33 1
	}
34
35
	/**
36
	 * To override for modifying the logout message
37
	 *
38
	 * @param FlashMessage $fMessage
39
	 */
40 1
	protected function terminateMessage(FlashMessage $fMessage) {
41 1
	}
42
43
	/**
44
	 * To override for modifying the disconnect message
45
	 *
46
	 * @param FlashMessage $fMessage
47
	 */
48
	protected function disconnectedMessage(FlashMessage $fMessage) {
49
	}
50
	
51
	/**
52
	 * To override for modifying the account creation message.
53
	 *
54
	 * @param FlashMessage $fMessage
55
	 */
56
	protected function createAccountMessage(FlashMessage $fMessage) {
1 ignored issue
show
Unused Code introduced by
The parameter $fMessage is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

56
	protected function createAccountMessage(/** @scrutinizer ignore-unused */ FlashMessage $fMessage) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
	}
58
	
59
	/**
60
	 * To override for modifying the account creation message information.
61
	 *
62
	 * @param FlashMessage $fMessage
63
	 */
64
	protected function canCreateAccountMessage(FlashMessage $fMessage) {
1 ignored issue
show
Unused Code introduced by
The parameter $fMessage is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
	protected function canCreateAccountMessage(/** @scrutinizer ignore-unused */ FlashMessage $fMessage) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
	}
66
	
67
	/**
68
	 * To override for modifying the error for account creation.
69
	 *
70
	 * @param FlashMessage $fMessage
71
	 */
72
	protected function createAccountErrorMessage(FlashMessage $fMessage) {
1 ignored issue
show
Unused Code introduced by
The parameter $fMessage is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

72
	protected function createAccountErrorMessage(/** @scrutinizer ignore-unused */ FlashMessage $fMessage) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
73
	}
74
	
75
	/**
76
	 * To override for modifying the 2FA panel message.
77
	 * @param FlashMessage $fMessage
78
	 */
79
	protected function twoFAMessage(FlashMessage $fMessage){
1 ignored issue
show
Unused Code introduced by
The parameter $fMessage is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

79
	protected function twoFAMessage(/** @scrutinizer ignore-unused */ FlashMessage $fMessage){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
80
		
81
	}
82
	/**
83
	 * To override
84
	 * @param FlashMessage $fMessage
85
	 */
86
	protected function newTwoFACodeMessage(FlashMessage $fMessage){
1 ignored issue
show
Unused Code introduced by
The parameter $fMessage is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

86
	protected function newTwoFACodeMessage(/** @scrutinizer ignore-unused */ FlashMessage $fMessage){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
87
		
88
	}
89
	
90
	/**
91
	 * To override for modifying the message displayed if the 2FA code is bad.
92
	 * @param FlashMessage $fMessage
93
	 */
94
	protected function twoFABadCodeMessage(FlashMessage $fMessage){
1 ignored issue
show
Unused Code introduced by
The parameter $fMessage is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

94
	protected function twoFABadCodeMessage(/** @scrutinizer ignore-unused */ FlashMessage $fMessage){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
95
		
96
	}
97
	
98
	/**
99
	 * To override 
100
	 * Displayed when email is valid.
101
	 * @param FlashMessage $fMessage
102
	 */
103
	protected function emailValidationSuccess(FlashMessage $fMessage){
1 ignored issue
show
Unused Code introduced by
The parameter $fMessage is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

103
	protected function emailValidationSuccess(/** @scrutinizer ignore-unused */ FlashMessage $fMessage){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
104
		
105
	}
106
	
107
	/**
108
	 * To override
109
	 * Displayed when email is invalid or if an error occurs.
110
	 * @param FlashMessage $fMessage
111
	 */
112
	protected function emailValidationError(FlashMessage $fMessage){
1 ignored issue
show
Unused Code introduced by
The parameter $fMessage is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

112
	protected function emailValidationError(/** @scrutinizer ignore-unused */ FlashMessage $fMessage){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
113
		
114
	}
115
116
	/**
117
	 * To override
118
	 * Returns the maximum number of allowed login attempts.
119
	 */
120 1
	protected function attemptsNumber() {
121 1
		return;
122
	}
123
124
	/**
125
	 * To override
126
	 * Returns the time before trying to connect again
127
	 * Effective only if attemptsNumber return a number.
128
	 *
129
	 * @return number
130
	 */
131
	protected function attemptsTimeout() {
132
		return 3 * 60;
133
	}
134
135
	/**
136
	 * Override to define if info is displayed as string
137
	 * if set to true, use _infoUser var in views to display user info
138
	 */
139 1
	public function _displayInfoAsString() {
140 1
		return false;
141
	}
142
143 1
	public function _checkConnectionTimeout() {
144 1
		return;
145
	}
146
147
	public function _getLoginInputName() {
148
		return 'email';
149
	}
150
151 1
	protected function loginLabel() {
152 1
		return \ucfirst ( $this->_getLoginInputName () );
153
	}
154
155 1
	public function _getPasswordInputName() {
156 1
		return 'password';
157
	}
158
159 1
	protected function passwordLabel() {
160 1
		return \ucfirst ( $this->_getPasswordInputName () );
161
	}
162
	
163
	protected function passwordConfLabel() {
164
		return \ucfirst ( $this->_getPasswordInputName () ).' confirmation';
165
	}
166
167
	/**
168
	 * Returns the body selector (jquery selector used for replacing the content of the page).
169
	 * default: body
170
	 *
171
	 * @return string
172
	 */
173 1
	public function _getBodySelector() {
174 1
		return 'body';
175
	}
176
177 1
	protected function rememberCaption() {
178 1
		return 'Remember me';
179
	}
180
	/**
181
	 * Returns true for account creation.
182
	 * @return boolean
183
	 */
184 1
	protected function hasAccountCreation():bool{
185 1
		return false;
186
	}
187
	
188
	/**
189
	 * 
190
	 * @return bool
191
	 */
192
	protected function hasEmailValidation():bool{
193
		return false;
194
	}
195
	
196
	/**
197
	 * To override
198
	 * Returns true for a two factor authentification for this account.
199
	 * @param mixed $accountValue
200
	 * @return bool
201
	 */
202 1
	protected function has2FA($accountValue=null):bool{
1 ignored issue
show
Unused Code introduced by
The parameter $accountValue is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

202
	protected function has2FA(/** @scrutinizer ignore-unused */ $accountValue=null):bool{

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
203 1
		return false;
204
	}
205
	
206
	/**
207
	 * 
208
	 * @return string
209
	 */
210
	protected function generate2FACode():string{
211
		return \substr(\md5(\uniqid(\rand(), true)), 6, 6);
212
	}
213
	
214
	protected function towFACodePrefix():string{
215
		return 'U-';
216
	}
217
	
218
	protected function emailValidationDuration():\DateInterval{
219
		return new \DateInterval('PT24H');
220
	}
221
	
222
}
223
224