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


PHP Password::make方法代码示例

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


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

示例1: resetPasswordAction

 function resetPasswordAction($db, $reset_key, $email_address, $password_token, $password, $user_password_repeat)
 {
     $response = $db->query('SELECT secret, request_timestamp FROM responses 
   WHERE reset_key = :reset_key AND email_address = :email_address 
   AND NOT used AND active', array(':reset_key' => $reset_key, ':email_address' => $email_address));
     $validatedPassword = self::validateUserPassword($password, $user_password_repeat);
     if (!$validatedPassword) {
         return "INVALID PASSWORD";
     }
     if ($response) {
         $created = DateTime::createFromFormat('Y-m-d G:i:s', $response[0]->request_timestamp);
         if ($created >= new DateTime('30 minutes ago')) {
             if (Password::verify($password_token, $response[0]->secret) && $password == $user_password_repeat) {
                 $disable_token = $db->update("responses", array('used' => 1), array('reset_key' => $reset_key), array());
                 $hash = Password::make($password, PASSWORD_BCRYPT, array("cost" => 10));
                 $password_change = $db->exec('UPDATE Users SET password = :password WHERE email = :email', array(':password' => $hash, ':email' => $email_address));
                 return "Password Successfully Changed";
             }
         }
     } else {
         return "INVALID RESET TOKEN";
     }
 }
开发者ID:sicoscorpion,项目名称:rpc-new,代码行数:23,代码来源:users.php

示例2: function

//   global $db;
//   $app = \Slim\Slim::getInstance();
//   $token = $app->request->headers->get('Authorization');
//   $token = str_replace('"', "", $token);
//   $tokenFromDB = Users_model::get_user_by_token($db, $token);
//   if (!$tokenFromDB) {
//     echoResponse(403, "Invalid Token");
//     exit();
//   }
// }
// Users
$app->post('/login', function () use($app) {
    global $db;
    $data = json_decode($app->request->getBody());
    $user = Users_model::get_hash($db, $data->email);
    $hash = Password::make($data->password, PASSWORD_BCRYPT, array("cost" => 10));
    if (Password::verify($data->password, $user[0]->password) == true) {
        echoResponse(200, $user[0]);
    } else {
        echoResponse(403, "Not a valid password");
    }
});
// 'authenticateToken',
$app->get('/users', 'authenticateToken', function () use($app) {
    global $db;
    $rows = Users_model::get_users($db);
    // foreach (getallheaders() as $name => $value) {
    // var_dump(getallheaders());
    // }
    echoResponse(200, $rows);
});
开发者ID:sicoscorpion,项目名称:rpc-new,代码行数:31,代码来源:users.php


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