function _user_external_invite_dehash in User External Invite 7
Same name and namespace in other branches
- 7.2 user_external_invite.module \_user_external_invite_dehash()
- 1.0.x user_external_invite.module \_user_external_invite_dehash()
Determine whether invite is accepted based on hash.
Given a key-token and mail, calculate expected hash, if same as key, return $rid of role to be granted.
1 call to _user_external_invite_dehash()
- user_external_invite_grant_invite in ./
user_external_invite.module - Grants an invite given a token and mail.
File
- ./
user_external_invite.module, line 748 - Invites a user to site when connecting via external protocol e.g. LDAP.
Code
function _user_external_invite_dehash($key, $mail) {
$result = db_select('user_external_invite', 'i')
->fields('i')
->condition('mail', $mail)
->execute()
->fetchAssoc();
if ($result['expire'] < REQUEST_TIME) {
// Token has expired.
// @todo: need a better error here.
return FALSE;
}
$expected_hash = _user_external_invite_calculate_hash($result['rid'], $result['mail'], $result['expire']);
if ($key == $expected_hash) {
return $result['rid'];
}
return FALSE;
}