function _urllogin_testuid in urllogin 6
Same name and namespace in other branches
- 7 urllogin.inc \_urllogin_testuid()
Tests to see if UID can be logged on.
Parameters
$uid: UID to be tested
$resultmsg: Contains resultmsg message if function fails.
Return value
If sucessful, loaded account of user Else NULL
2 calls to _urllogin_testuid()
- urllogin_link_page in ./
urllogin.inc - This is the function that actually performs the login.
- urllogin_test_page in ./
urllogin.inc - Diagnostic test page for setting up urllogin urls.
File
- ./
urllogin.inc, line 153
Code
function _urllogin_testuid($uid, &$resultmsg) {
if ($uid < 2) {
$resultmsg = t('UID is %uid - cannot login as user 0 or 1', array(
'%uid' => $uid,
));
return NULL;
}
$account = user_load($uid);
if (!$account) {
$resultmsg = t('User %uid does not exist', array(
'%uid' => $uid,
));
return NULL;
}
if (!user_access('login via url', $account)) {
$resultmsg = t('User %uid denied access', array(
'%uid' => $uid,
));
return NULL;
}
$resultmsg = t('User %username (%uid) successfully validated', array(
'%username' => $account->name,
'%uid' => $uid,
));
return $account;
}