89 lines
2.8 KiB
PHP
89 lines
2.8 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\teamapi\controller;
|
||
|
||
use app\common\cache\StoreUserTokenCache;
|
||
use app\common\model\store\StoreUserSession;
|
||
use app\teamapi\logic\TeamLoginLogic;
|
||
use app\teamapi\validate\{LoginAccountValidate, PasswordValidate, WechatLoginValidate};
|
||
|
||
/**
|
||
* 登录注册
|
||
* Class LoginController
|
||
* @package app\api\controller
|
||
*/
|
||
class TeamLoginController extends BaseApiController
|
||
{
|
||
|
||
public array $notNeedLogin = [ 'account', 'logout', 'codeUrl','resetPassword'];
|
||
|
||
|
||
|
||
/**
|
||
* @notes 账号密码/手机号密码/手机号验证码登录
|
||
* @return \think\response\Json
|
||
* @author 段誉
|
||
* @date 2022/9/16 10:42
|
||
*/
|
||
public function account()
|
||
{
|
||
// $userTokenCache = new StoreUserTokenCache();
|
||
// $userSession = StoreUserSession::where([['user_id', '=', 1], ['terminal', '=', 1]])->find();
|
||
// $userTokenCache->deleteUserInfo($userSession->token);
|
||
$params = (new LoginAccountValidate())->post()->goCheck();
|
||
$result = TeamLoginLogic::login($params);
|
||
if (false === $result) {
|
||
return $this->fail(TeamLoginLogic::getError());
|
||
}
|
||
return $this->data($result);
|
||
}
|
||
|
||
/**
|
||
* @notes 重置密码
|
||
* @return \think\response\Json
|
||
* @author 胥聪
|
||
* @date 2025/12/16 14:30
|
||
*/
|
||
public function resetPassword()
|
||
{
|
||
$params = (new PasswordValidate())->post()->goCheck('resetPassword');
|
||
$result = TeamLoginLogic::resetPassword($params);
|
||
if (true === $result) {
|
||
return $this->success('操作成功', [], 1, 1);
|
||
}
|
||
return $this->fail(TeamLoginLogic::getError());
|
||
}
|
||
/**
|
||
* @notes 退出登录
|
||
* @return \think\response\Json
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author 段誉
|
||
* @date 2022/9/16 10:42
|
||
*/
|
||
public function logout()
|
||
{
|
||
TeamLoginLogic::logout($this->userInfo);
|
||
return $this->success();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |