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


PHP User::checkNewPasswordStrength方法代码示例

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


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

示例1: postContent

 function postContent()
 {
     $this->reverseGatekeeper();
     $name = $this->getInput('name');
     $handle = trim($this->getInput('handle'));
     $password = trim($this->getInput('password'));
     $email = trim($this->getInput('email'));
     if (empty($handle) && empty($email)) {
         \Idno\Core\site()->session()->addErrorMessage("Please enter a username and email address.");
     } else {
         if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
             if (!($emailuser = \Idno\Entities\User::getByEmail($email)) && !($handleuser = \Idno\Entities\User::getByHandle($handle)) && !empty($handle) && strlen($handle) <= 32 && !substr_count($handle, '/') && \Idno\Entities\User::checkNewPasswordStrength($password)) {
                 $user = new Application();
                 $user->email = $email;
                 $user->handle = strtolower(trim($handle));
                 // Trim the handle and set it to lowercase
                 $user->setPassword($password);
                 $user->notifications['email'] = 'all';
                 if (empty($name)) {
                     $name = $user->handle;
                 }
                 $user->setTitle($name);
                 if ($user->save()) {
                     $t = clone \Idno\Core\site()->template();
                     $t->setTemplateType('email');
                     foreach (\Idno\Core\site()->getAdmins() as $admin) {
                         $email_message = new Email();
                         $email_message->setSubject("You have a new membership application!");
                         $email_message->addTo($admin->email);
                         $email_message->setHTMLBodyFromTemplate('applytojoin/new', ['user' => $user]);
                         $email_message->send();
                     }
                     $this->forward(\Idno\Core\site()->config()->getDisplayURL() . 'account/join/thanks/');
                 } else {
                     var_export(\Idno\Core\site()->session()->messages);
                 }
             } else {
                 if (empty($handle)) {
                     \Idno\Core\site()->session()->addErrorMessage("Please create a username.");
                 }
                 if (strlen($handle) > 32) {
                     \Idno\Core\site()->session()->addErrorMessage("Your username is too long.");
                 }
                 if (substr_count($handle, '/')) {
                     \Idno\Core\site()->session()->addErrorMessage("Usernames can't contain a slash ('/') character.");
                 }
                 if (!empty($handleuser)) {
                     \Idno\Core\site()->session()->addErrorMessage("Unfortunately, someone is already using that username. Please choose another.");
                 }
                 if (!empty($emailuser)) {
                     \Idno\Core\site()->session()->addErrorMessage("Hey, it looks like there's already an account with that email address. Did you forget your login?");
                 }
                 if (!\Idno\Entities\User::checkNewPasswordStrength($password)) {
                     \Idno\Core\site()->session()->addErrorMessage("Please check that your password is at least 7 characters long.");
                 }
             }
         }
     }
     $this->forward(\Idno\Core\site()->config()->getDisplayURL() . 'account/join/');
 }
开发者ID:sensiblemn,项目名称:ApplyToJoin,代码行数:60,代码来源:Join.php

示例2: postContent

 function postContent()
 {
     $this->reverseGatekeeper();
     $code = $this->getInput('code');
     $email = $this->getInput('email');
     $password = trim($this->getInput('password'));
     $password2 = trim($this->getInput('password2'));
     if (\Idno\Entities\User::checkNewPasswordStrength($password) && $password == $password2) {
         if ($user = \Idno\Entities\User::getByEmail($email)) {
             if ($code = $user->getPasswordRecoveryCode()) {
                 /* @var \Idno\Entities\User $user */
                 $user->setPassword($password);
                 $user->clearPasswordRecoveryCode();
                 $user->save();
                 \Idno\Core\site()->session()->addMessage("Your password was reset!");
             }
         }
     } else {
         \Idno\Core\site()->session()->addErrorMessage('Sorry, your passwords either don\'t match, or are too weak', 'alert-error');
         $this->forward($_SERVER['HTTP_REFERER']);
     }
 }
开发者ID:johnellison,项目名称:90days,代码行数:22,代码来源:Reset.php

示例3: postContent

 function postContent()
 {
     $this->createGatekeeper();
     // Logged-in only please
     $user = \Idno\Core\site()->session()->currentUser();
     $name = $this->getInput('name');
     $email = $this->getInput('email');
     $password = trim($this->getInput('password'));
     $username = trim($this->getInput('handle'));
     /*if (!\Idno\Common\Page::isSSL() && !\Idno\Core\site()->config()->disable_cleartext_warning) {
           \Idno\Core\site()->session()->addErrorMessage("Warning: Access credentials were sent over a non-secured connection! To disable this warning set disable_cleartext_warning in your config.ini");
       }*/
     if (!empty($name)) {
         $user->setTitle($name);
     }
     if (!empty($username) && $username != $user->getHandle()) {
         $user->setHandle($username);
     }
     if (!empty($email) && $email != $user->email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
         if (!\Idno\Entities\User::getByEmail($email)) {
             $user->email = $email;
         } else {
             \Idno\Core\site()->session()->addErrorMessage('Someone is already using ' . $email . ' as their email address.');
         }
     }
     if (!empty($password)) {
         if (\Idno\Entities\User::checkNewPasswordStrength($password)) {
             \Idno\Core\site()->session()->addMessage("Your password has been updated.");
             $user->setPassword($password);
         } else {
             \Idno\Core\site()->session()->addErrorMessage('Sorry, your password is too weak');
         }
     }
     if ($user->save()) {
         \Idno\Core\site()->session()->addMessage("Your details were saved.");
     }
     $this->forward($_SERVER['HTTP_REFERER']);
 }
开发者ID:hank,项目名称:Known,代码行数:38,代码来源:Settings.php

示例4: postContent

 function postContent()
 {
     $name = $this->getInput('name');
     $handle = trim($this->getInput('handle'));
     $password = trim($this->getInput('password'));
     $password2 = trim($this->getInput('password2'));
     $email = trim($this->getInput('email'));
     $code = $this->getInput('code');
     $onboarding = $this->getInput('onboarding');
     /*if (!\Idno\Common\Page::isSSL() && !\Idno\Core\site()->config()->disable_cleartext_warning) {
           \Idno\Core\site()->session()->addErrorMessage("Warning: Access credentials were sent over a non-secured connection! To disable this warning set disable_cleartext_warning in your config.ini");
       }*/
     if (empty(\Idno\Core\site()->config()->open_registration)) {
         if (!($invitation = \Idno\Entities\Invitation::validate($email, $code))) {
             \Idno\Core\site()->session()->addErrorMessage("Your invitation doesn't seem to be valid, or has expired.");
             $this->forward(\Idno\Core\site()->config()->getURL());
         } else {
             // Removing this from here - invitation will be deleted once user is created
             //$invitation->delete(); // Remove the invitation; it's no longer needed
         }
     }
     $user = new \Idno\Entities\User();
     if (empty($handle) && empty($email)) {
         \Idno\Core\site()->session()->addErrorMessage("Please enter a username and email address.");
     } else {
         if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
             if (!($emailuser = \Idno\Entities\User::getByEmail($email)) && !($handleuser = \Idno\Entities\User::getByHandle($handle)) && !empty($handle) && strlen($handle) <= 32 && preg_match('/^[a-zA-Z0-9_]{1,}$/', $handle) && !substr_count($handle, '/') && $password == $password2 & \Idno\Entities\User::checkNewPasswordStrength($password)) {
                 $user = new \Idno\Entities\User();
                 $user->email = $email;
                 $user->handle = strtolower(trim($handle));
                 // Trim the handle and set it to lowercase
                 $user->setPassword($password);
                 $user->notifications['email'] = 'all';
                 if (empty($name)) {
                     $name = $user->handle;
                 }
                 $user->setTitle($name);
                 if (!\Idno\Entities\User::get()) {
                     $user->setAdmin(true);
                     $user->robot_state = '1';
                     // State for our happy robot helper
                     if (\Idno\Core\site()->config()->title == 'New Known site') {
                         if (!empty($_SESSION['set_name'])) {
                             \Idno\Core\site()->config()->title = $_SESSION['set_name'];
                         } else {
                             \Idno\Core\site()->config()->title = $user->getTitle() . '\'s Known';
                         }
                         \Idno\Core\site()->config()->theme = 'Solo';
                         \Idno\Core\site()->config()->open_registration = false;
                         \Idno\Core\site()->config()->from_email = $user->email;
                         \Idno\Core\site()->config()->save();
                     }
                     \Idno\Core\site()->triggerEvent('site/firstadmin', array('user' => $user));
                     // Event hook for first admin
                 } else {
                     \Idno\Core\site()->triggerEvent('site/newuser', array('user' => $user));
                     // Event hook for new user
                 }
                 $user->save();
                 // Now we can remove the invitation
                 if (!empty($invitation)) {
                     if ($invitation instanceof Invitation) {
                         $invitation->delete();
                         // Remove the invitation; it's no longer needed
                     }
                 }
             } else {
                 if (empty($handle)) {
                     \Idno\Core\site()->session()->addErrorMessage("Please create a username.");
                 }
                 if (strlen($handle) > 32) {
                     \Idno\Core\site()->session()->addErrorMessage("Your username is too long.");
                 }
                 if (!preg_match('/^[a-zA-Z0-9_]{1,}$/', $handle)) {
                     \Idno\Core\site()->session()->addErrorMessage("Usernames can only have letters, numbers and underscores.");
                 }
                 if (substr_count($handle, '/')) {
                     \Idno\Core\site()->session()->addErrorMessage("Usernames can't contain a slash ('/') character.");
                 }
                 if (!empty($handleuser)) {
                     \Idno\Core\site()->session()->addErrorMessage("Unfortunately, someone is already using that username. Please choose another.");
                 }
                 if (!empty($emailuser)) {
                     \Idno\Core\site()->session()->addErrorMessage("Hey, it looks like there's already an account with that email address. Did you forget your login?");
                 }
                 if (!\Idno\Entities\User::checkNewPasswordStrength($password) || $password != $password2) {
                     \Idno\Core\site()->session()->addErrorMessage("Please check that your passwords match and that your password is at least 7 characters long.");
                 }
             }
         } else {
             \Idno\Core\site()->session()->addErrorMessage("That doesn't seem like it's a valid email address.");
         }
     }
     if (!empty($user->_id)) {
         \Idno\Core\site()->session()->addMessage("You've registered! You're ready to get started. Why not add a status update to say hello?");
         \Idno\Core\site()->session()->logUserOn($user);
         if (empty($onboarding)) {
             $this->forward();
         } else {
             $this->forward(\Idno\Core\site()->config()->getURL() . 'begin/profile');
//.........这里部分代码省略.........
开发者ID:uniteddiversity,项目名称:Known,代码行数:101,代码来源:Register.php


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