modified 完善三方账号登录

This commit is contained in:
zhaoxiang 2020-10-12 19:01:13 +08:00
parent dd62e2cdd1
commit 692baef59e
2 changed files with 7 additions and 7 deletions

View File

@ -8,7 +8,7 @@
[![ApiAdmin](https://img.shields.io/badge/ApiAdmin-5.0.0-brightgreen.svg)](http://www.apiadmin.org/)
## 前端页面
ApiAdmin4.1是一个前后端完全分离的项目前端采用Vue构建如需要可视化配置的请移步[ApiAdmin-WEB](https://gitee.com/apiadmin/ApiAdmin-WEB)
ApiAdmin5.0是一个前后端完全分离的项目前端采用Vue构建如需要可视化配置的请移步[ApiAdmin-WEB](https://gitee.com/apiadmin/ApiAdmin-WEB)
## 快速安装

View File

@ -298,8 +298,8 @@ class ThirdLogin extends Base {
* @throws \think\db\exception\ModelNotFoundException
* @author zhaoxiang <zhaoxiang051405@gmail.com>
*/
private function doLogin($openid, $userDetail): Response {
$userInfo = AdminUser::get(['openid' => $openid]);
private function doLogin(string $openid, array $userDetail): Response {
$userInfo = (new AdminUser())->where('openid', $openid)->find();
if (empty($userInfo)) {
$userInfo = AdminUser::create([
'nickname' => $userDetail['nickname'],
@ -313,7 +313,7 @@ class ThirdLogin extends Base {
$userDataArr = [
'login_times' => 1,
'uid' => $userInfo->id,
'last_login_ip' => $this->request->ip(1),
'last_login_ip' => sprintf("%u", ip2long($this->request->ip())),
'last_login_time' => time(),
'head_img' => $userDetail['head_img']
];
@ -328,7 +328,7 @@ class ThirdLogin extends Base {
if ($userInfo['status']) {
//更新用户数据
$userInfo->userData->login_times++;
$userInfo->userData->last_login_ip = $this->request->ip(1);
$userInfo->userData->last_login_ip = sprintf("%u", ip2long($this->request->ip()));
$userInfo->userData->last_login_time = time();
$userInfo->userData->save();
} else {
@ -336,8 +336,8 @@ class ThirdLogin extends Base {
}
}
$userInfo['access'] = (new Login())->getAccess($userInfo['id']);
$userInfo['menu'] = (new Login())->getAccessMenu($userInfo['id']);
$userInfo['access'] = (new Login(App()))->getAccess($userInfo['id']);
$userInfo['menu'] = (new Login(App()))->getAccessMenuData($userInfo['id']);
$apiAuth = md5(uniqid() . time());
cache('Login:' . $apiAuth, json_encode($userInfo), config('apiadmin.ONLINE_TIME'));