Révision dd54aff9
Ajouté par Assos Assos il y a plus de 10 ans
htmltest/sites/all/modules/ldap/ldap_authentication/ldap_authentication.module | ||
---|---|---|
29 | 29 |
define('LDAP_AUTHENTICATION_EMAIL_FIELD_ALLOW', 4); |
30 | 30 |
define('LDAP_AUTHENTICATION_EMAIL_FIELD_DEFAULT', 3); |
31 | 31 |
|
32 |
define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_NONE', 1); |
|
33 |
define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_ALWAYS', 2); |
|
34 |
define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_IF_EMPTY', 3); |
|
35 |
define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_DEFAULT', 3); |
|
36 |
|
|
37 |
define('LDAP_AUTHENTICATION_DEFAULT_TEMPLATE', '@username@fake-domain.com'); |
|
38 |
|
|
39 |
define('LDAP_AUTHENTICATION_DEFAULT_TEMPLATE_REGEX', '.*@fake-domain\\.com'); |
|
40 |
|
|
41 |
define('LDAP_AUTHENTICATION_TEMPLATE_USAGE_NEVER_UPDATE_DEFAULT', 0); |
|
42 |
define('LDAP_AUTHENTICATION_TEMPLATE_USAGE_RESOLVE_CONFLICT_DEFAULT', 0); |
|
43 |
define('LDAP_AUTHENTICATION_TEMPLATE_USAGE_PROMPT_USER_DEFAULT', 0); |
|
44 |
|
|
32 | 45 |
define('LDAP_AUTHENTICATION_PASSWORD_FIELD_SHOW', 2); |
33 | 46 |
define('LDAP_AUTHENTICATION_PASSWORD_FIELD_HIDE', 3); |
34 | 47 |
define('LDAP_AUTHENTICATION_PASSWORD_FIELD_ALLOW', 4); |
... | ... | |
52 | 65 |
define('LDAP_AUTHENTICATION_DISABLED_FOR_BAD_CONF_MSG' , 'The site logon is currently not working due to a configuration error. Please see logs for additional details.'); |
53 | 66 |
define('LDAP_AUTHENTICATION_COOKIE_EXPIRE', 0); |
54 | 67 |
|
68 |
define('LDAP_AUTHENTICATION_REDIRECT_ON_LOGIN_DEFAULT', 0); |
|
69 |
|
|
55 | 70 |
/** |
56 | 71 |
* Implements hook_menu(). |
57 | 72 |
*/ |
58 | 73 |
function ldap_authentication_menu() { |
59 | 74 |
$items = array(); |
60 | 75 |
|
76 |
$items['user/ldap-profile-update'] = array( |
|
77 |
'title' => 'Update Profile', |
|
78 |
'page callback' => 'drupal_get_form', |
|
79 |
'page arguments' => array('ldap_authentication_profile_update_form'), |
|
80 |
'access callback' => TRUE, |
|
81 |
'type' => MENU_CALLBACK, |
|
82 |
'file' => 'ldap_authentication.pages.inc', |
|
83 |
); |
|
84 |
|
|
61 | 85 |
$items['admin/config/people/ldap/authentication'] = array( |
62 | 86 |
'title' => 'Authentication', |
63 | 87 |
'description' => 'Configure LDAP Authentication', |
... | ... | |
156 | 180 |
} |
157 | 181 |
} |
158 | 182 |
|
183 |
/** |
|
184 |
* Helper function that determines whether or not the user's profile |
|
185 |
* is valid or needs to be updated on login. |
|
186 |
* |
|
187 |
* Currently this only checks if mail is valid or not according to the |
|
188 |
* authentication settings. |
|
189 |
* |
|
190 |
* @return boolean |
|
191 |
* TRUE if the user's profile is valid, otherwise FALSE. |
|
192 |
* |
|
193 |
*/ |
|
194 |
function _ldap_authentication_verify_user_profile() { |
|
195 |
global $user; |
|
196 |
$result = TRUE; |
|
197 |
// We only want non-anonymous and non-1 users. |
|
198 |
if ($user->uid > 1) { |
|
199 |
// we store the value in the session for speed. |
|
200 |
if (isset($_SESSION['ldap_authentication_template']) && |
|
201 |
isset($_SESSION['ldap_authentication_template']['verify_user_profile'])) { |
|
202 |
return $_SESSION['ldap_authentication_template']['verify_user_profile']; |
|
203 |
} |
|
204 |
if (ldap_authentication_ldap_authenticated($user)) { |
|
205 |
$auth_conf = ldap_authentication_get_valid_conf(); |
|
206 |
$regex = '`' . $auth_conf->templateUsagePromptRegex . '`i'; |
|
207 |
if (preg_match($regex, $user->mail)) { |
|
208 |
$result = FALSE; |
|
209 |
} |
|
210 |
$_SESSION['ldap_authentication_template'] = array( |
|
211 |
'verify_user_profile' => $result, |
|
212 |
); |
|
213 |
} |
|
214 |
} |
|
215 |
return TRUE; |
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
219 |
* Implements hook_init(). |
|
220 |
*/ |
|
221 |
function ldap_authentication_init() { |
|
222 |
$auth_conf = ldap_authentication_get_valid_conf(); |
|
223 |
if ($auth_conf->templateUsagePromptUser) { |
|
224 |
ldap_authentication_check_for_email_template(); |
|
225 |
} |
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* Form submit callback to check for an email template and redirect if needed. |
|
230 |
*/ |
|
231 |
function ldap_authentication_check_for_email_template() { |
|
232 |
if (!_ldap_authentication_verify_user_profile()) { |
|
233 |
$url = 'user/ldap-profile-update'; |
|
234 |
$cp = current_path(); |
|
235 |
// avoid redirects on these two pages. |
|
236 |
if ($cp != $url && $cp != 'user/logout') { |
|
237 |
if (isset($_GET['destination'])) { |
|
238 |
unset($_GET['destination']); |
|
239 |
} |
|
240 |
drupal_goto($url, array( |
|
241 |
'query' => array( |
|
242 |
'next' => current_path(), |
|
243 |
), |
|
244 |
)); |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
159 | 249 |
/** |
160 | 250 |
* Implements hook_info(). |
161 | 251 |
*/ |
Formats disponibles : Unified diff
Weekly update of contrib modules