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


PHP Encrypt::encryptPwd方法代码示例

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


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

示例1: registerAction

 /**
  * 确认注册【设定密码】
  * @method registerAction
  * @return [type]         [description]
  * @author NewFuture
  */
 public function registerAction()
 {
     $msg = '信息注册失败!';
     if ($regInfo = Session::get('reg')) {
         Session::del('reg');
         if (Input::post('password', $password, 'trim') === false) {
             /*密码未md5*/
             $this->error('密码错误', '/');
         } elseif (!$password) {
             /*未设置密码*/
             $password = $regInfo['password'];
         }
         $regInfo['password'] = Encrypt::encryptPwd($password, $regInfo['number']);
         if ($id = UserModel::insert($regInfo)) {
             /*注册成功*/
             $regInfo['id'] = $id;
             $token = Auth::token($regInfo);
             Cookie::set('token', [$id => $token]);
             unset($regInfo['password']);
             Session::set('user', $regInfo);
             $msg = '信息注册成功!';
         }
     }
     $this->jump('/', $msg);
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:31,代码来源:Api.php

示例2: POST_indexAction

 /**
  * 打印店登录
  * @method loginAction
  * @return [type]      [description]
  * @author NewFuture
  */
 public function POST_indexAction()
 {
     $response['status'] = 0;
     if (!Input::post('account', $account, Config::get('regex.account'))) {
         $response['info'] = '账号格式错误';
     } elseif (!Input::post('password', $password, 'isMd5')) {
         $response['info'] = '密码未加密处理';
     } elseif (!Safe::checkTry('printer_auth_' . $account)) {
         $response['info'] = '尝试次数过多账号临时封禁,稍后重试或者联系我们';
     } elseif (!($Printer = PrinterModel::where('account', $account)->field('id,sch_id,password,status,name')->find())) {
         $response['info'] = '账号错误';
     } elseif (Encrypt::encryptPwd($password, $account) != $Printer['password']) {
         $response['info'] = '密码错误';
     } else {
         Safe::del('printer_auth_' . $account);
         unset($Printer['password']);
         $sid = Session::start();
         Session::set('printer', ['id' => $Printer['id'], 'sch_id' => $Printer['sch_id']]);
         $response['status'] = 1;
         $response['info'] = ['sid' => $sid, 'printer' => $Printer];
     }
     $this->response = $response;
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:29,代码来源:Auth.php

示例3: login

 /**
  * 登录函数
  * @method login
  * @access private
  * @author NewFuture[newfuture@yunyin.org]
  * @param  [string]   $password    [md5密码]
  * @return [bool/int] [用户id]
  */
 private function login($number, $password, $sch_id = null)
 {
     $conditon = ['number' => $number];
     //指定学校
     $sch_id and $conditon['sch_id'] = $sch_id;
     $users = UserModel::where($conditon)->select('id,password,sch_id,name');
     if (empty($users)) {
         /*未注册*/
         return null;
     } else {
         /*验证结果*/
         $password = Encrypt::encryptPwd($password, $number);
         $reg_schools = [];
         foreach ($users as &$user) {
             if ($user['password'] == $password) {
                 /*登录成功*/
                 $user['number'] = $number;
                 $token = Auth::token($user);
                 $sessionid = Session::start();
                 unset($user['password']);
                 Session::set('user', $user);
                 Cookie::set('token', $token);
                 // $user['school'] = SchoolModel::getName($user['sch_id']);
                 $result = ['sid' => $sessionid, 'user' => $user, 'msg' => '登录成功!', 'token' => $token];
                 $this->response(1, $result);
                 return true;
             } else {
                 /*验证失败*/
                 $sid = $user['sch_id'];
                 $reg_schools[$sid] = School::getAbbr($sid);
             }
         }
         $this->reg_schools = $reg_schools;
         return false;
     }
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:44,代码来源:Auth.php

示例4: create

 /**
  * 创建用户
  * @method create
  * @param  [type] $data [description]
  * @return [type]       [description]
  * @author NewFuture
  */
 public function create($data)
 {
     $userInfo = array();
     /*姓名*/
     if (!(isset($data['name']) && $data['name'])) {
         $this->error = '姓名有误!';
         return false;
     } else {
         $userInfo['name'] = $data['name'];
     }
     /*学号*/
     if (!(isset($data['number']) && is_numeric($data['number']))) {
         $this->error = '学号必须';
         return false;
     } else {
         $userInfo['number'] = $data['number'];
     }
     /*密码*/
     if (!isset($data['password'])) {
         $this->error = '密码必须';
         return false;
     } else {
         $userInfo['password'] = Encrypt::encryptPwd($data['password'], $data['number']);
     }
     /*学校*/
     if (isset($data['sch_id'])) {
         $userInfo['sch_id'] = intval($data['sch_id']);
     }
     /*存入数据库*/
     if ($uid = parent::getModel()->insert($userInfo)) {
         return $uid;
     } else {
         $this->error = '保存失败';
         return false;
     }
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:43,代码来源:User.php

示例5: PUT_infoAction

 /**
  * 修改用户信息[密码]
  * PUT /user/1
  * @method PUT_infoAction
  * @param  integer        $id [description]
  * @author NewFuture
  */
 public function PUT_infoAction($id = 0)
 {
     $id = $this->auth($id);
     $response['status'] = 0;
     if (!Input::put('password', $password, 'isMd5')) {
         $response['info'] = '新的密码格式不对';
     } elseif (!Input::put('old', $old_pwd, 'isMd5')) {
         $response['info'] = '请输入原密码';
     } else {
         /*数据库中读取用户数据*/
         $user = UserModel::field('password,number')->find($id);
         $number = $user->number;
         if (!$user || Encrypt::encryptPwd($old_pwd, $number) != $user['password']) {
             $response['info'] = '原密码错误';
         } elseif (UserModel::set('password', Encrypt::encryptPwd($password, $number))->save($id) >= 0) {
             $response['info'] = '修改成功';
             $response['status'] = 1;
         } else {
             $response['info'] = '修改失败';
         }
     }
     $this->response = $response;
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:30,代码来源:User.php

示例6: PUT_indexAction

 /**
  * 重置密码
  * @method POST_printerAction
  * @author NewFuture
  */
 public function PUT_indexAction($id)
 {
     $this->auth($id);
     $response['status'] = 0;
     if (!Input::put('password', $password, 'isMd5')) {
         $response['info'] = '新的密码格式不对';
     } elseif (!Input::put('old', $old_pwd, 'isMd5')) {
         $response['info'] = '请输入原密码';
     } else {
         /*数据库中读取用户数据*/
         $printer = PrinterModel::field('password,account')->find($id);
         $account = $printer['account'];
         if (!$printer || Encrypt::encryptPwd($old_pwd, $account) != $printer['password']) {
             $response['info'] = '原密码错误';
         } elseif ($printer->update(['password' => Encrypt::encryptPwd($password, $account)]) >= 0) {
             $response['info'] = '修改成功';
             $response['status'] = 1;
         } else {
             $response['info'] = '修改失败';
         }
     }
     $this->response = $response;
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:28,代码来源:Password.php


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