You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
1.9 KiB
PHTML
89 lines
1.9 KiB
PHTML
2 years ago
|
<?php
|
||
|
|
||
|
namespace Open\Controller;
|
||
|
|
||
|
|
||
|
use Admin\Model\DevelopersModel;
|
||
|
use Open\Model\OpenMessageModel;
|
||
|
|
||
|
class UserController extends BaseController
|
||
|
{
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 注册
|
||
|
* @param $account
|
||
|
* @param $password
|
||
|
* @param $code
|
||
|
* author: xmy 280564871@qq.com
|
||
|
*/
|
||
|
public function register($account,$password,$code){
|
||
|
//检查验证码
|
||
|
$result = check_verify($code,2);
|
||
|
if(!$result){
|
||
|
$this->error("验证码错误");
|
||
|
}
|
||
|
//实例化注册
|
||
|
$model = new DevelopersModel();
|
||
|
if($result && $model->register($account,$password)){
|
||
|
$model = new OpenMessageModel();
|
||
|
$model->sendMsg(session("user_info.uid"),"注册成功",'恭喜您,您已成功注册开发者平台账号');
|
||
|
$this->success("注册成功",U("Apply/apply"));
|
||
|
}else{
|
||
|
$this->success("注册失败:".$model->getError());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 登录
|
||
|
* @param $account
|
||
|
* @param $password
|
||
|
* @param $code
|
||
|
* author: xmy 280564871@qq.com
|
||
|
*/
|
||
|
public function login($account,$password,$code){
|
||
|
//检查验证码
|
||
|
$result = check_verify($code,1);
|
||
|
if(!$result){
|
||
|
$this->error("验证码错误");
|
||
|
}
|
||
|
//实例化注册
|
||
|
$model = new DevelopersModel();
|
||
|
$uid = $model->login($account,$password);
|
||
|
if($result && $uid > 0){
|
||
|
$model->updateLoginTime($uid);
|
||
|
$this->success("登录成功",U("Stats/overview"));
|
||
|
}else{
|
||
|
$this->success("登录失败:".$model->getError());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 登出
|
||
|
* author: xmy 280564871@qq.com
|
||
|
*/
|
||
|
public function logout(){
|
||
|
$model = new DevelopersModel();
|
||
|
$model->logout();
|
||
|
$this->redirect("index/index");
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 修改密码
|
||
|
* @param $old
|
||
|
* @param $new
|
||
|
* author: xmy 280564871@qq.com
|
||
|
*/
|
||
|
public function alter_password($old,$new){
|
||
|
$model = new DevelopersModel();
|
||
|
$uid = session("user_info.uid");
|
||
|
$result = $model->alterPwd($uid,$old,$new);
|
||
|
if($result !== false){
|
||
|
$this->success("修改成功");
|
||
|
}else{
|
||
|
$this->error("修改失败:".$model->getError());
|
||
|
}
|
||
|
}
|
||
|
}
|