/** * Set a registration key for this User * @return true if successful else false. */ function resetRegistrationKey() { global $DB, $CFG, $HUB_SQL; $registrationKey = createRegistrationKey(); $params = array(); $params[0] = $registrationKey; $params[1] = '0'; $params[2] = $CFG->USER_STATUS_UNVALIDATED; $params[3] = $this->userid; $res = $DB->insert($HUB_SQL->DATAMODEL_USER_REGISTRATION_KEY_RESET, $params); if (!$res) { return false; } else { if (count($resArray) == 0) { return false; } else { return true; } } return false; }
//# 3 - else, here lets check if the user email we got from the provider already exists in our database ( for this example the email is UNIQUE for each user ) // if authentication does not exist, but the email address returned by the provider does exist in database, // then we tell the user that the email is already in use //echo $email; if (isset($email) && $email != "") { $u = new User(); $u->setEmail($email); $user = $u->getByEmail(); if ($user instanceof User) { $isEmailValidated = $user->isEmailValidated(); $status = $user->getStatus(); if ($isEmailValidated && ($status == $CFG->USER_STATUS_ACTIVE || $status == $CFG->USER_STATUS_REPORTED)) { // if there is an existing account with a validated email address // create an user authentication record and log them in // MERGE PROFILES? $registrationKey = createRegistrationKey(); $authentication = new UserAuthentication(); $authentication->add($user->userid, $provider, $provideruid, $email, $registrationKey); // email validation has happened through service provider so do not need to revalidate. if ($email == $emailVerified) { $authentication->completeVerification($registrationKey); createSession($user); $user->resetInvitationCode(); // hang over from Cohere groups code header('Location: ' . ''); } else { // send email for validate ownership of email given. $paramArray = array($u->name, $CFG->SITE_TITLE, $CFG->homeAddress, $authentication->authid, $registrationKey, urlencode($referrer)); sendMail("validateexternal", $LNG->VALIDATE_REGISTER_SUBJECT, $u->getEmail(), $paramArray); if (empty($errors)) { $message = $LNG->LOGIN_EXTERNAL_FIRST_TIME . " " . $providerDisplay;