/**
  * Try and load a UserAuthentication account from the gicen provider and provder user id.
  * @param $provider the provider
  * @param $userproviderid the user provider id
  * returns an UserAuthentication instance else return Error;
  */
 function loadByProvider($provider, $userproviderid)
 {
     global $DB, $HUB_SQL;
     $params = array();
     $params[0] = $provider;
     $params[1] = $userproviderid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_USER_AUTH_LOAD_BY_PROVIDER, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createUserNotFoundError($this->authid);
             return $ERROR;
         } else {
             //Should only every be one
             $authentication = new UserAuthentication($resArray[0]['AuthID']);
             $authentication->load();
             return $authentication;
         }
     } else {
         return database_error();
     }
 }
Exemplo n.º 2
0
//if(isset($USER->userid) || $CFG->signupstatus == $CFG->SIGNUP_CLOSED){
//    header('Location: '.$CFG->homeAddress.'index.php');
//    return;
//}
$id = trim(required_param("id", PARAM_TEXT));
$key = trim(required_param("key", PARAM_TEXT));
$referrer = optional_param("referrer", $CFG->homeAddress . "index.php", PARAM_URL);
if ($referrer == "") {
    $referrer = $CFG->homeAddress . "index.php";
}
if (empty($id) || empty($key)) {
    header('Location: ' . $CFG->homeAddress . 'index.php');
    return;
}
$auth = new UserAuthentication($id);
$userauth = $auth->load();
$errors = array();
if ($userauth instanceof UserAuthentication && $userauth->validateRegistrationKey($key)) {
    if ($userauth->completeVerification($key)) {
        $user = new User($userauth->getUserID());
        if ($user instanceof User) {
            $status = $user->getStatus();
            if ($status == $CFG->USER_STATUS_ACTIVE || $status == $CFG->USER_STATUS_REPORTED) {
                createSession($user);
                header('Location: ' . $referrer);
                die;
            } else {
                if ($status == $CFG->USER_STATUS_UNVALIDATED) {
                    array_push($errors, $LNG->LOGIN_EXTERNAL_ERROR_ACCOUNT_UNVALIDATED);
                } else {
                    if ($status == $CFG->USER_STATUS_UNAUTHORIZED) {
Exemplo n.º 3
0
}
$errors = array();
$provider = required_param("provider", PARAM_ALPHA);
$providerDisplay = ucfirst($provider);
$referrer = optional_param("referrer", $CFG->homeAddress . "index.php", PARAM_URL);
if ($referrer == "") {
    $referrer = $CFG->homeAddress . "index.php";
}
$showEmailForm = false;
$revalidateEmail = false;
// USER ASKED ANOTHER VALIDATION EMAIL FOR A NEW ACCOUNT
if (isset($_POST["validateemail"])) {
    // send email to validate email address
    $authid = required_param("authid", PARAM_TEXT);
    $auth = new UserAuthentication($authid);
    $authentication = $auth->load();
    if ($authentication instanceof UserAuthentication && !$authentication->isEmailVerified()) {
        $u = new User($authentication->getUserID());
        $user = $u->load();
        if ($user instanceof User && !$user->isEmailValidated() && strcmp($user->getRegistrationKey(), $authentication->getRegistrationKey()) == 0) {
            $registrationKey = $user->getRegistrationKey();
            // send email for validate ownership of email given, Validate email as External.
            $paramArray = array($user->name, $CFG->SITE_TITLE, $CFG->homeAddress, $user->userid, $authentication->authid, $registrationKey, urlencode($referrer));
            sendMail("validateexternalnewuser", $LNG->VALIDATE_REGISTER_SUBJECT, $user->getEmail(), $paramArray);
            include_once $HUB_FLM->getCodeDirPath("ui/headerlogin.php");
            echo "<div class='messagediv2'><h1>" . $LNG->LOGIN_EXTERNAL_TITLE . "</h1><p>" . $LNG->LOGIN_EXTERNAL_EMAIL_VERIFICALTION_MESSAGE . "</p></dir>";
            include_once $HUB_FLM->getCodeDirPath("ui/footer.php");
            die;
        } else {
            //
        }