本文整理汇总了PHP中Password类的典型用法代码示例。如果您正苦于以下问题:PHP Password类的具体用法?PHP Password怎么用?PHP Password使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Password类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRender
/**
* @covers Xoops\Form\Password::render
*/
public function testRender()
{
$value = $this->object->render();
$this->assertTrue(is_string($value));
$this->assertTrue(false !== strpos($value, '<input'));
$this->assertTrue(false !== strpos($value, 'type="password"'));
}
示例2: login
public function login()
{
$pass = new Password($this->password);
$db = new DB();
$db->where(['email' => $this->email, 'username' => $this->username], 'AND', "OR");
$db->where(['password' => $this->password], 'AND');
$data = $db->getRow($this->table);
//_print_r($data);
if (count($data) > 0 && $pass->verifyPassword()) {
if ($n = $pass->needRehash()) {
$newHash = $pass->reHashPassword();
$db->where(['email' => $this->email, 'username' => $this->username], 'AND', "OR");
$db->where(['password' => $this->password], 'AND');
$res = $db->update($this->table, ['hash' => $newHash]);
}
/************ SET SESSION VARIABLES HERE **************/
//session_start();
$_SESSION['logged'] = TRUE;
$_SESSION['userid'] = $data->id;
$_SESSION['username'] = $data->username ? $data->username : "";
/****************** END SESSION SETTINGS **************/
return $data;
} else {
return FALSE;
}
}
示例3: sameValueAs
/**
* @param ValueObject $other
*
* @return bool
*/
public function sameValueAs(Password $other)
{
if (!$other instanceof self) {
return false;
}
return $this->toString() === $other->toString();
}
示例4: testCompile
public function testCompile()
{
$field = new Password("test", "Test");
$expected = "<label for=\"test\">Test</label><input type=\"password\" name=\"test\" value=\"\" />";
$value = $field->compile();
$this->assertEquals($expected, $value);
}
示例5: token
function token()
{
global $instDir, $objMessages, $entryMessage;
// Get the userid
include_once $instDir . "lib/password.php";
$password = new Password();
$token = $_GET['t'];
$userid = $password->getUserId($token);
if (sizeof($userid) > 0) {
// Clear the request
$password->removeToken($token);
// Send a mail that the request was canceled.
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$subject = LangCancelRequestNewPasswordSubject;
$message = LangCancelRequestNewPassword1 . $ip;
$message .= LangCancelRequestNewPassword2;
$objMessages->sendEmail($subject, $message, $userid);
// Go to the DeepskyLog page and show 'Your password change request was canceled'
$entryMessage = LangCancelRequestNewPasswordSubject . ".";
}
}
示例6: login
function login() {
try {
$A = new Auth();
} catch(Exception $e) {
die($e->getMessage());
}
if($_POST['password']) {
$P = new Password();
if(!$P->isValid($_POST['password'])) {
$pass_incorrect = true;
} else {
$set_cookie = true;
$cookieval = set_auth_cookie();
try {
$A->create($cookieval);
} catch(Exception $e) {
die($e->getMessage());
}
}
} else {
if(isset($_COOKIE['auth']) && $A->isValid($_COOKIE['auth']))
$already_set = true;
}
?>
<!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_cookie): ?>
<p>Y'all should be logged in now.</p>
<?php elseif($already_set): ?>
<p>Y'all is already logged in.</p>
<?php else: ?>
<form method="post">
<input name="password" type="password" placeholder="Password?" \>
<input type="submit" value="Login" />
</form>
</body>
</html>
<?php endif;
}
示例7: setPasswordField
public function setPasswordField($data, $value)
{
$pwd = new Password();
if ($value == $data->get(self::PASSWORD)) {
return $value;
}
return $pwd->hash($value);
}
示例8: init
public static function init($name, $value, $attrs = null)
{
$p = new Password($name, $value);
if ($attrs) {
$p->add_attrs($attrs);
}
return $p;
}
示例9: login
public function login($username, $password)
{
$pass = new Password();
$hashed = $this->get_user_hash($username);
$stmt = $pass->password_verify($password, $hashed);
if ($stmt == 1) {
$_SESSION['loggedin'] = true;
return $stmt;
}
}
示例10: getTokenValue
/**
* Get a CSRF Token value as stored in the session, or create one if it doesn't yet exist
*
* @param int|string|null $id Optional unique ID for this token
* @return string
*
*/
public function getTokenValue($id = '')
{
$tokenName = $this->getTokenName($id);
$tokenValue = $this->session->get($this, $tokenName);
if (empty($tokenValue)) {
// $tokenValue = md5($this->page->path() . mt_rand() . microtime()) . md5($this->page->name . $this->config->userAuthSalt . mt_rand());
$pass = new Password();
$tokenValue = $pass->randomBase64String(32);
$this->session->set($this, $tokenName, $tokenValue);
}
return $tokenValue;
}
示例11: isValid
public static function isValid(&$properties_dictionary, $limit_to_keys, &$error)
{
// Check each property is valid
//
if (!parent::isValid($properties_dictionary, $limit_to_keys, $error)) {
return false;
}
if (ValidationC::should_test_property('rawEmail', $properties_dictionary, true, $limit_to_keys) && !Email::propertyIsValid('rawEmail', $properties_dictionary[USER_KEY_EMAIL], $error)) {
// Email was not valid
//
return false;
}
if (ValidationC::should_test_property('rawPassword', $properties_dictionary, true, $limit_to_keys) && !Password::propertyIsValid('rawPassword', $properties_dictionary[USER_KEY_PASSWORD], $error)) {
// Password was not valid
//
return false;
}
if (isset($properties_dictionary[USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS])) {
if (ValidationC::should_test_property(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS, $properties_dictionary, true, $limit_to_keys) && !User::propertyIsValid(USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS, $properties_dictionary[USER_KEY_NOTIFICATION_DEVICE_IDENTIFIERS], $error)) {
// Password was not valid
//
return false;
}
}
return true;
}
示例12: postReset
/**
* Handle a POST request to reset a user's password.
*
* @return Response
*/
public function postReset()
{
$post = Input::all();
$rules = array('email' => 'required|email', 'password' => 'required', 'password_confirmation' => 'required');
$validator = Validator::make($post, $rules);
if ($validator->fails()) {
return Redirect::to('recordar/form/' . $post['token'])->withErrors($validator)->withInput();
} else {
$credentials = Input::only('email', 'password', 'password_confirmation', 'token');
$response = Password::reset($credentials, function ($user, $password) {
$user->password = Hash::make($password);
$user->password_changed = true;
$user->save();
});
switch ($response) {
case Password::INVALID_PASSWORD:
case Password::INVALID_TOKEN:
case Password::INVALID_USER:
return Redirect::back()->with('error', Lang::get($response));
case Password::PASSWORD_RESET:
Session::flash('success', 'Su contraseña ha sido cambiada exitósamente.');
return Redirect::to('login');
}
}
}
示例13: testResetPasswordSuccess
public function testResetPasswordSuccess()
{
// check reset password success
Password::shouldReceive('reset')->once()->andReturn('passwords.reset');
$checkResetPassword = $this->call('POST', '/passwords/reset', ['token' => 'token', 'email' => 'admin@example.com', 'password' => '12345678', 'password_confirmation' => '12345678']);
$this->assertEquals(200, $checkResetPassword->getStatusCode());
}
示例14: login
public function login()
{
/**
* function that allows the user to login
* @param password $pass password of the user
* @param $filter to validate that the password is correct
* @param $auth to authorize the entrance to de system
*
* @return void
*/
if ($_POST) {
$pass = new Password();
$filter = new Validations();
$auth = new Authorization();
$username = $filter->sanitizeText($_POST['username']);
$password = $filter->sanitizeText($_POST['password']);
$options = array('conditions' => "username = '{$username}'");
$usuario = $this->db->find('usuarios', 'first', $options);
if ($pass->isValid($password, $usuario['password'])) {
$auth->login($usuario);
$this->redirect(array('controller' => 'tareas'));
} else {
echo "Usuario no valido";
}
}
$this->_view->renderizar('login');
}
示例15: resetPassword
protected function resetPassword($credentials)
{
return Password::reset($credentials, function ($user, $pass) {
$user->password = Hash::make($pass);
$user->save();
});
}