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


PHP Password::randomBase64String方法代码示例

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


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

示例1: 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

示例2: ___login

 /**
  * Login a user with the given name and password
  *
  * Also sets them to the current user
  *
  * @param string $name
  * @param string $pass Raw, non-hashed password
  * @return User Return the $user if the login was successful or null if not. 
  *
  */
 public function ___login($name, $pass)
 {
     $name = $this->wire('sanitizer')->pageName($name);
     if (!$this->allowLogin($name)) {
         $this->loginFailure($name, "User is not allowed to login");
         return null;
     }
     $user = strlen($name) ? $this->wire('users')->get("name={$name}") : null;
     if ($user && $user->id && $user->id != $this->wire('config')->guestUserPageID && $this->authenticate($user, $pass)) {
         $this->trackChange('login', $this->wire('user'), $user);
         session_regenerate_id(true);
         $this->set('_user', 'id', $user->id);
         $this->set('_user', 'ts', time());
         if ($this->config->sessionChallenge) {
             // create new challenge
             $pass = new Password();
             $challenge = $pass->randomBase64String(32);
             $this->set('_user', 'challenge', $challenge);
             // set challenge cookie to last 30 days (should be longer than any session would feasibly last)
             setcookie(session_name() . '_challenge', $challenge, time() + 60 * 60 * 24 * 30, '/', null, false, true);
         }
         if ($this->config->sessionFingerprint) {
             // remember a fingerprint that tracks the user's IP and user agent
             $this->set('_user', 'fingerprint', $this->getFingerprint());
         }
         $this->setFuel('user', $user);
         $this->get('CSRF')->resetAll();
         $this->loginSuccess($user);
         return $user;
     } else {
         if (!$user || !$user->id) {
             $reason = "Unknown user: {$name}";
         } else {
             if ($user->id == $this->wire('config')->guestUserPageID) {
                 $reason = "Guest user may not login";
             } else {
                 $reason = "Invalid password";
             }
         }
         $this->loginFailure($name, $reason);
     }
     return null;
 }
开发者ID:Rizsti,项目名称:Processwire_Compatibility,代码行数:53,代码来源:Session.php

示例3: ___login

 /**
  * Login a user with the given name and password
  *
  * Also sets them to the current user
  *
  * @param string $name
  * @param string $pass Raw, non-hashed password
  * @return User Return the $user if the login was successful or null if not. 
  *
  */
 public function ___login($name, $pass)
 {
     if (!$this->allowLogin($name)) {
         return null;
     }
     $name = $this->wire('sanitizer')->username($name);
     $user = $this->wire('users')->get("name={$name}");
     if ($user->id && $this->authenticate($user, $pass)) {
         $this->trackChange('login', $this->wire('user'), $user);
         session_regenerate_id(true);
         $this->set('_user', 'id', $user->id);
         $this->set('_user', 'ts', time());
         if ($this->config->sessionChallenge) {
             // create new challenge
             $pass = new Password();
             $challenge = $pass->randomBase64String(32);
             $this->set('_user', 'challenge', $challenge);
             // set challenge cookie to last 30 days (should be longer than any session would feasibly last)
             setcookie(session_name() . '_challenge', $challenge, time() + 60 * 60 * 24 * 30, '/', null, false, true);
         }
         if ($this->config->sessionFingerprint) {
             // remember a fingerprint that tracks the user's IP and user agent
             $this->set('_user', 'fingerprint', md5($this->getIP(true) . $_SERVER['HTTP_USER_AGENT']));
         }
         $this->setFuel('user', $user);
         $this->get('CSRF')->resetAll();
         $this->loginSuccess($user);
         return $user;
     }
     return null;
 }
开发者ID:avatar382,项目名称:fablab_site,代码行数:41,代码来源:Session.php


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