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


PHP Password::exists方法代码示例

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


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

示例1: get

 public function get($key, $request)
 {
     if (Password::exists(array('key' => $key))) {
         $pass = Password::find_by_key($key);
         $user = User::find($pass->user_id);
         $pass->delete();
         $pass = Password::generatePass(9);
         $user->pass = password_hash($pass, PASSWORD_BCRYPT);
         $user->save();
         $data = array();
         $data['currentPageTitle'] = 'Connexion';
         $resp = new ViewResponse('login/login', $data);
         $resp->addMessage(ViewMessage::success('Voici votre nouveau mot de passe: <b>' . $pass . '</b>. Connectez-vous dès maintenant !'));
         return $resp;
     } else {
         $data = array();
         $data['currentPageTitle'] = 'Mot de passe oublié';
         $resp = new ViewResponse('password/password', $data);
         $resp->addMessage(ViewMessage::error('Clé invalide ou expirée, merci de recommencer la procédure'));
         return $resp;
     }
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:22,代码来源:password_controller.php

示例2: setpw

function setpw() {

  try {
    $P = new Password();
    $pass_exists = $P->exists();
  } catch(Exception $e) {
    die($e->getMessage());
  }

  if($_POST['newpass']) {

    if($pass_exists && !$P->isValid($_POST['password'])) {
      $pass_incorrect = true;
    } else {
      $confirm_failed = $_POST['newpass'] != $_POST['passconfirm'];

      // (Try to) set the password
      if(!$confirm_failed) {
        try {
          $set_pass = $P->set($_POST['newpass'], $db);
        } catch(Exception $e) {
          die($e->getMessage());
        }
      }
    }
  }
  ?>

  <!DOCTYPE html>
  <html>
  <head><title>set scraps password</title></head>
  <body>

  <?php if($pass_incorrect): ?>

    <p>The password entered does not match the current password.</p>

  <?php elseif($set_pass): ?>

    <p>Password set successfully.</p>

  <?php else: ?>

    <?php if($confirm_failed): ?>
    <p>The passwords you entered don't match.</p>
    <?php endif; ?>

    <form method="post">

    <?php if($pass_exists): ?>
    <input name="password" type="password" placeholder="Current password?" \>
    <?php endif; ?>

    <input name="newpass" type="password" placeholder="New password"\>
    <input name="passconfirm" type="password" placeholder="Confirm new password" \>
    <input type="submit" value="Set Password" />
    </form>

    </body>
    </html>

  <?php endif;
}
开发者ID:nham,项目名称:scraps,代码行数:63,代码来源:index.php


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