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


PHP UserMapper::verifyThisTestUser方法代码示例

本文整理汇总了PHP中UserMapper::verifyThisTestUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMapper::verifyThisTestUser方法的具体用法?PHP UserMapper::verifyThisTestUser怎么用?PHP UserMapper::verifyThisTestUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserMapper的用法示例。


在下文中一共展示了UserMapper::verifyThisTestUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postAction

 public function postAction($request, $db)
 {
     // check element 3, there's no user associated with the not-logged-in collections
     if (isset($request->url_elements[3])) {
         switch ($request->url_elements[3]) {
             case 'verifications':
                 $user_mapper = new UserMapper($db, $request);
                 $token = filter_var($request->getParameter("token"), FILTER_SANITIZE_STRING);
                 if (empty($token)) {
                     throw new Exception("Verification token must be supplied", 400);
                 } else {
                     $success = $user_mapper->verifyUser($token);
                     if ($success) {
                         header("Content-Length: 0", null, 204);
                         exit;
                         // no more content
                     } else {
                         throw new Exception("Verification failed", 400);
                     }
                 }
                 break;
             default:
                 throw new InvalidArgumentException('Unknown Subrequest', 404);
                 break;
         }
     } else {
         $user = array();
         $errors = array();
         $user_mapper = new UserMapper($db, $request);
         // Required Fields
         $user['username'] = filter_var(trim($request->getParameter("username")), FILTER_SANITIZE_STRING);
         if (empty($user['username'])) {
             $errors[] = "'username' is a required field";
         } else {
             // does anyone else have this username?
             $existing_user = $user_mapper->getUserByUsername($user['username']);
             if ($existing_user['users']) {
                 $errors[] = "That username is already in use. Choose another";
             }
         }
         $user['full_name'] = filter_var(trim($request->getParameter("full_name")), FILTER_SANITIZE_STRING);
         if (empty($user['full_name'])) {
             $errors[] = "'full_name' is a required field";
         }
         $user['email'] = filter_var(trim($request->getParameter("email")), FILTER_VALIDATE_EMAIL);
         if (empty($user['email'])) {
             $errors[] = "A valid entry for 'email' is required";
         } else {
             // does anyone else have this email?
             $existing_user = $user_mapper->getUserByEmail($user['email']);
             if ($existing_user['users']) {
                 $errors[] = "That email is already associated with another account";
             }
         }
         $password = $request->getParameter("password");
         if (empty($password)) {
             $errors[] = "'password' is a required field";
         } else {
             // check it's sane
             $validity = $user_mapper->checkPasswordValidity($password);
             if (true === $validity) {
                 // OK good, go ahead
                 $user['password'] = $password;
             } else {
                 // the password wasn't acceptable, tell the user why
                 $errors = array_merge($errors, $validity);
             }
         }
         // Optional Fields
         $user['twitter_username'] = filter_var(trim($request->getParameter("twitter_username")), FILTER_SANITIZE_STRING);
         // How does it look?  With no errors, we can proceed
         if ($errors) {
             throw new Exception(implode(". ", $errors), 400);
         } else {
             $user_id = $user_mapper->createUser($user);
             header("Location: " . $request->base . $request->path_info . '/' . $user_id, null, 201);
             // autoverify for test platforms
             if (isset($this->config['features']['allow_auto_verify_users']) && $this->config['features']['allow_auto_verify_users']) {
                 if ($request->getParameter("auto_verify_user") == "true") {
                     // the test suite sends this extra field, if we got
                     // this far then this platform supports this
                     $user_mapper->verifyThisTestUser($user_id);
                 }
             }
             // Generate a verification token and email it to the user
             $token = $user_mapper->generateEmailVerificationTokenForUserId($user_id);
             $recipients = array($user['email']);
             $emailService = new UserRegistrationEmailService($this->config, $recipients, $token);
             $emailService->sendEmail();
             exit;
         }
     }
 }
开发者ID:asgrim,项目名称:joindin-api,代码行数:93,代码来源:UsersController.php


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