-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthorization.php
More file actions
122 lines (88 loc) · 3.68 KB
/
Copy pathauthorization.php
File metadata and controls
122 lines (88 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
include_once dirname(__FILE__) . '/' . 'phpgen_settings.php';
include_once dirname(__FILE__) . '/' . 'components/application.php';
include_once dirname(__FILE__) . '/' . 'components/security/permission_set.php';
include_once dirname(__FILE__) . '/' . 'components/security/user_authentication/table_based_user_authentication.php';
include_once dirname(__FILE__) . '/' . 'components/security/grant_manager/table_based_user_grant_manager.php';
include_once dirname(__FILE__) . '/' . 'components/security/table_based_user_manager.php';
include_once dirname(__FILE__) . '/' . 'components/security/user_identity_storage/user_identity_session_storage.php';
include_once dirname(__FILE__) . '/' . 'components/security/recaptcha.php';
include_once dirname(__FILE__) . '/' . 'database_engine/mysql_engine.php';
$dataSourceRecordPermissions = array();
$tableCaptions = array('categories' => 'التصنيف',
'lessons' => 'الدروس');
$usersTableInfo = array(
'TableName' => 'users',
'UserId' => 'user_id',
'UserName' => 'user_email',
'Password' => 'user_password',
'Email' => 'user_email',
'UserToken' => 'user_token',
'UserStatus' => 'user_status'
);
function EncryptPassword($password, &$result)
{
}
function VerifyPassword($enteredPassword, $encryptedPassword, &$result)
{
}
function BeforeUserRegistration($userName, $email, $password, &$allowRegistration, &$errorMessage)
{
}
function AfterUserRegistration($userName, $email)
{
}
function PasswordResetRequest($userName, $email)
{
}
function PasswordResetComplete($userName, $email)
{
}
function VerifyPasswordStrength($password, &$result, &$passwordRuleMessage)
{
}
function CreatePasswordHasher()
{
$hasher = CreateHasher('MD5');
if ($hasher instanceof CustomStringHasher) {
$hasher->OnEncryptPassword->AddListener('EncryptPassword');
$hasher->OnVerifyPassword->AddListener('VerifyPassword');
}
return $hasher;
}
function CreateGrantManager()
{
global $tableCaptions;
global $usersTableInfo;
$userPermsTableInfo = array('TableName' => 'user_perms', 'UserId' => 'user_id', 'PageName' => 'page_name', 'Grant' => 'perm_name');
return new TableBasedUserGrantManager(MySqlIConnectionFactory::getInstance(), GetGlobalConnectionOptions(),
$usersTableInfo, $userPermsTableInfo, $tableCaptions, false);
}
function CreateTableBasedUserManager()
{
global $usersTableInfo;
$userManager = new TableBasedUserManager(MySqlIConnectionFactory::getInstance(), GetGlobalConnectionOptions(),
$usersTableInfo, CreatePasswordHasher(), true);
$userManager->OnVerifyPasswordStrength->AddListener('VerifyPasswordStrength');
return $userManager;
}
function GetReCaptcha($formId)
{
$reCaptcha = new GoogleReCaptcha('6LdEYkIdAAAAAOsFmlg7nvbfrfyOKmSyFIwM7B2c', '6LdEYkIdAAAAAEGMGslN9SLHGptTuJA0BBZrzagn', GoogleReCaptchaType::Checkbox, true);
$formsProtectedByReCaptcha = array('registration', 'resend_verification_email', 'password_recovery');
if (in_array($formId, $formsProtectedByReCaptcha)) {
return $reCaptcha;
} else {
return null;
}
}
function SetUpUserAuthorization()
{
global $dataSourceRecordPermissions;
$hasher = CreatePasswordHasher();
$grantManager = CreateGrantManager();
$userAuthentication = new TableBasedUserAuthentication(new UserIdentitySessionStorage(), false, $hasher, CreateTableBasedUserManager(), true, true, true);
GetApplication()->SetUserAuthentication($userAuthentication);
GetApplication()->SetUserGrantManager($grantManager);
GetApplication()->SetDataSourceRecordPermissionRetrieveStrategy(new HardCodedDataSourceRecordPermissionRetrieveStrategy($dataSourceRecordPermissions));
}