本文整理汇总了PHP中UserController::redirectOnVerify方法的典型用法代码示例。如果您正苦于以下问题:PHP UserController::redirectOnVerify方法的具体用法?PHP UserController::redirectOnVerify怎么用?PHP UserController::redirectOnVerify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserController
的用法示例。
在下文中一共展示了UserController::redirectOnVerify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUser
/**
* Creates a native user in Omegaup and returns the DAO populated
*
* @param string $username optional
* @param string $password optional
* @param string $email optional
* @return user (DAO)
*/
public static function createUser($username = null, $password = null, $email = null, $verify = true)
{
// If data is not provided, generate it randomly
if (is_null($username)) {
$username = Utils::CreateRandomString();
}
if (is_null($password)) {
$password = Utils::CreateRandomString();
}
if (is_null($email)) {
$email = Utils::CreateRandomString() . '@mail.com';
}
// Populate a new Request to pass to the API
UserController::$permissionKey = uniqid();
$r = new Request(array('username' => $username, 'name' => $username, 'password' => $password, 'email' => $email, 'permission_key' => UserController::$permissionKey));
// Call the API
$response = UserController::apiCreate($r);
// If status is not OK
if (strcasecmp($response['status'], 'ok') !== 0) {
throw new Exception('UserFactory::createUser failed');
}
// Get user from db
$user = UsersDAO::FindByUsername($username);
if ($verify) {
UserController::$redirectOnVerify = false;
$user = self::verifyUser($user);
} else {
$user->verified = 0;
UsersDAO::save($user);
}
// Password came hashed from DB. Set password in plaintext
$user->setPassword($password);
return $user;
}
示例2: apiVerifyEmail
/**
* Verifies the user given its verification id
*
* @param Request $r
* @return type
* @throws ApiException
* @throws InvalidDatabaseOperationException
* @throws NotFoundException
*/
public static function apiVerifyEmail(Request $r)
{
$user = null;
// Admin can override verification by sending username
if (isset($r['usernameOrEmail'])) {
self::authenticateRequest($r);
if (!Authorization::IsSystemAdmin($r['current_user_id'])) {
throw new ForbiddenAccessException();
}
self::$log->info('Admin verifiying user...' . $r['usernameOrEmail']);
Validators::isStringNonEmpty($r['usernameOrEmail'], 'usernameOrEmail');
$user = self::resolveUser($r['usernameOrEmail']);
self::$redirectOnVerify = false;
} else {
// Normal user verification path
Validators::isStringNonEmpty($r['id'], 'id');
try {
$users = UsersDAO::search(new Users(array('verification_id' => $r['id'])));
$user = is_array($users) && count($users) > 0 ? $users[0] : null;
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
}
if (is_null($user)) {
throw new NotFoundException('verificationIdInvalid');
}
try {
$user->setVerified(1);
UsersDAO::save($user);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
self::$log->info('User verification complete.');
self::registerToSendy($user);
if (self::$redirectOnVerify) {
die(header('Location: /login/'));
}
return array('status' => 'ok');
}