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


PHP Password类代码示例

本文整理汇总了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"'));
 }
开发者ID:redmexico,项目名称:XoopsCore,代码行数:10,代码来源:PasswordTest.php

示例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;
     }
 }
开发者ID:akhtar-husain,项目名称:Mini-Framework,代码行数:26,代码来源:Auth.class.php

示例3: sameValueAs

 /**
  * @param ValueObject $other
  *
  * @return bool
  */
 public function sameValueAs(Password $other)
 {
     if (!$other instanceof self) {
         return false;
     }
     return $this->toString() === $other->toString();
 }
开发者ID:wysow,项目名称:domain-application,代码行数:12,代码来源:Password.php

示例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);
 }
开发者ID:jenwachter,项目名称:html-form,代码行数:7,代码来源:PasswordTest.php

示例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 . ".";
    }
}
开发者ID:rolfvandervleuten,项目名称:DeepskyLog,代码行数:27,代码来源:removeToken.php

示例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;
}
开发者ID:nham,项目名称:scraps,代码行数:59,代码来源:index.php

示例7: setPasswordField

 public function setPasswordField($data, $value)
 {
     $pwd = new Password();
     if ($value == $data->get(self::PASSWORD)) {
         return $value;
     }
     return $pwd->hash($value);
 }
开发者ID:DavBfr,项目名称:BlogMVC,代码行数:8,代码来源:UsersModel.class.php

示例8: init

 public static function init($name, $value, $attrs = null)
 {
     $p = new Password($name, $value);
     if ($attrs) {
         $p->add_attrs($attrs);
     }
     return $p;
 }
开发者ID:DaniloEpic,项目名称:slast,代码行数:8,代码来源:Formulario.php

示例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;
     }
 }
开发者ID:ekobudis,项目名称:isias,代码行数:10,代码来源:class.Users.php

示例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;
 }
开发者ID:avatar382,项目名称:fablab_site,代码行数:19,代码来源:SessionCSRF.php

示例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;
 }
开发者ID:adamcarter93,项目名称:university-final-year-project-rest-api,代码行数:26,代码来源:User.php

示例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');
         }
     }
 }
开发者ID:frankpaul142,项目名称:cloudinventory,代码行数:30,代码来源:RemindersController.php

示例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());
 }
开发者ID:wyrover,项目名称:laravel-users,代码行数:7,代码来源:PasswordControllerTest.php

示例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');
 }
开发者ID:karhega,项目名称:framework,代码行数:27,代码来源:usuariosController.php

示例15: resetPassword

 protected function resetPassword($credentials)
 {
     return Password::reset($credentials, function ($user, $pass) {
         $user->password = Hash::make($pass);
         $user->save();
     });
 }
开发者ID:shinichi81,项目名称:laravel-4-authentication,代码行数:7,代码来源:UserController.php


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