本文整理汇总了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;
}
}
示例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;
}