1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Quantum PHP Framework |
5
|
|
|
* |
6
|
|
|
* An open source software development framework for PHP |
7
|
|
|
* |
8
|
|
|
* @package Quantum |
9
|
|
|
* @author Arman Ag. <[email protected]> |
10
|
|
|
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) |
11
|
|
|
* @link http://quantum.softberg.org/ |
12
|
|
|
* @since 2.5.0 |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Quantum\Exceptions; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class AuthException |
19
|
|
|
* @package Quantum\Exceptions |
20
|
|
|
*/ |
21
|
|
|
class AuthException extends \Exception |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Incorrect auth credentials message |
25
|
|
|
*/ |
26
|
|
|
const INCORRECT_AUTH_CREDENTIALS = 'Incorrect credentials'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Incorrect auth credentials message |
30
|
|
|
*/ |
31
|
|
|
const INACTIVE_ACCOUNT = 'The account is not activated'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Incorrect verification code |
35
|
|
|
*/ |
36
|
|
|
const INCORRECT_VERIFICATION_CODE = 'Incorrect verification code.'; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Verification code expiry in |
40
|
|
|
*/ |
41
|
|
|
const VERIFICATION_CODE_EXPIRED = 'Verification code expired'; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Misconfigured session handler message |
45
|
|
|
*/ |
46
|
|
|
const MISCONFIGURED_AUTH_CONFIG = 'Auth config is not properly configured'; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Incorrect user schema |
50
|
|
|
*/ |
51
|
|
|
const INCORRECT_USER_SCHEMA = 'User schema does not contains all key fields'; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return \Quantum\Exceptions\AuthException |
55
|
|
|
*/ |
56
|
|
|
public static function incorrectCredentials(): AuthException |
57
|
|
|
{ |
58
|
|
|
return new static(self::INCORRECT_AUTH_CREDENTIALS); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return \Quantum\Exceptions\AuthException |
63
|
|
|
*/ |
64
|
|
|
public static function inactiveAccount(): AuthException |
65
|
|
|
{ |
66
|
|
|
return new static(self::INACTIVE_ACCOUNT); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return \Quantum\Exceptions\AuthException |
71
|
|
|
*/ |
72
|
|
|
public static function incorrectVerificationCode(): AuthException |
73
|
|
|
{ |
74
|
|
|
return new static(self::INCORRECT_VERIFICATION_CODE); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return \Quantum\Exceptions\AuthException |
79
|
|
|
*/ |
80
|
|
|
public static function verificationCodeExpired(): AuthException |
81
|
|
|
{ |
82
|
|
|
return new static(self::VERIFICATION_CODE_EXPIRED); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return \Quantum\Exceptions\AuthException |
87
|
|
|
*/ |
88
|
|
|
public static function misconfiguredAuthConfig(): AuthException |
89
|
|
|
{ |
90
|
|
|
return new static(self::MISCONFIGURED_AUTH_CONFIG); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return \Quantum\Exceptions\AuthException |
95
|
|
|
*/ |
96
|
|
|
public static function incorrectUserSchema(): AuthException |
97
|
|
|
{ |
98
|
|
|
return new static(self::INCORRECT_USER_SCHEMA); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|