当前位置: 首页>>代码示例>>PHP>>正文


PHP UserController::redirectOnVerify方法代码示例

本文整理汇总了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;
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:42,代码来源:UserFactory.php

示例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');
 }
开发者ID:RicardoMelgoza,项目名称:omegaup,代码行数:48,代码来源:UserController.php


注:本文中的UserController::redirectOnVerify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。