游戏陪玩系统源码开发,实现登陆功能需要如何做?

游戏陪玩系统源码开发,实现登陆功能需要如何做?

登录功能的实现,是用户使用游戏陪玩系统源码的第一步,如果登录功能都没有开发好,那就无法给用户留下好的第一印象,所以今天我们就一起来看看在游戏陪玩系统源码开发中,实现登陆功能需要如何做吧。Login.php(validate)<?phpnamespaceapp\common\validate;usethink\Validate;classLoginextendsValidate{protected$rule=['username'=>'require|max:20','password'=>'require|max:20',];}app.php<?phpreturn['password_pre_halt'=>'_#sing_ty',//密码加密言];IAuth.php<?phpnamespaceapp\common\lib;classIAuth{publicstaticfunctionsetPassword($data){returnmd5($data.config('app.password_pre_halt'));}}修改Admin.php(controller)$data['password']=IAuth::setPassword($data['password']);Login.php(controller)<?php/***CreatedbyPhpStorm.*User:tong*Date:2017/10/31*Time:15:37*/namespaceapp\admin\controller;useapp\common\lib\IAuth;usethink\Controller;classLoginextendsController{publicfunctionindex(){return$this->fetch();}/***登陆相关业务*/publicfunctioncheck(){if(request()->isPost()){$data=input('post.');if(!captcha_check($data['code'])){$this->error('验证码不正确');}//判定usernamepassword$validate=validate('Login');if(!$validate->check($data)){$this->error($validate->getError());}$user=model('AdminUser')->get(['username'=>$data['username']]);if(!$user||$user->status!=1){$this->error('该用户不存在');}if(IAuth::setPassword($data['password'])!=$user['password']){$this->error("密码不正确");}}else{$this->error("请求不合法");}}}看起来似乎并不难,为了给用户带去更好的使用体验,登录功能还需要不断的优化,如果能支持更多登录方式,用户就有了更多可以选择的余地,以上就是“游戏陪玩系统源码开发,实现登陆功能需要如何做?”的全部内容了,希望对大家有帮助。本文转载自网络,转载仅为分享干货知识,如有侵权欢迎联系云豹科技进行删除处理原文链接:

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Proudly powered by WordPress | Theme: HoneyWaves by SpiceThemes