mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 完善三方账号登录
This commit is contained in:
parent
dd62e2cdd1
commit
692baef59e
@ -8,7 +8,7 @@
|
|||||||
[](http://www.apiadmin.org/)
|
[](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)
|
||||||
|
|
||||||
## 快速安装
|
## 快速安装
|
||||||
|
|
||||||
|
@ -298,8 +298,8 @@ class ThirdLogin extends Base {
|
|||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
private function doLogin($openid, $userDetail): Response {
|
private function doLogin(string $openid, array $userDetail): Response {
|
||||||
$userInfo = AdminUser::get(['openid' => $openid]);
|
$userInfo = (new AdminUser())->where('openid', $openid)->find();
|
||||||
if (empty($userInfo)) {
|
if (empty($userInfo)) {
|
||||||
$userInfo = AdminUser::create([
|
$userInfo = AdminUser::create([
|
||||||
'nickname' => $userDetail['nickname'],
|
'nickname' => $userDetail['nickname'],
|
||||||
@ -313,7 +313,7 @@ class ThirdLogin extends Base {
|
|||||||
$userDataArr = [
|
$userDataArr = [
|
||||||
'login_times' => 1,
|
'login_times' => 1,
|
||||||
'uid' => $userInfo->id,
|
'uid' => $userInfo->id,
|
||||||
'last_login_ip' => $this->request->ip(1),
|
'last_login_ip' => sprintf("%u", ip2long($this->request->ip())),
|
||||||
'last_login_time' => time(),
|
'last_login_time' => time(),
|
||||||
'head_img' => $userDetail['head_img']
|
'head_img' => $userDetail['head_img']
|
||||||
];
|
];
|
||||||
@ -328,7 +328,7 @@ class ThirdLogin extends Base {
|
|||||||
if ($userInfo['status']) {
|
if ($userInfo['status']) {
|
||||||
//更新用户数据
|
//更新用户数据
|
||||||
$userInfo->userData->login_times++;
|
$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->last_login_time = time();
|
||||||
$userInfo->userData->save();
|
$userInfo->userData->save();
|
||||||
} else {
|
} else {
|
||||||
@ -336,8 +336,8 @@ class ThirdLogin extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$userInfo['access'] = (new Login())->getAccess($userInfo['id']);
|
$userInfo['access'] = (new Login(App()))->getAccess($userInfo['id']);
|
||||||
$userInfo['menu'] = (new Login())->getAccessMenu($userInfo['id']);
|
$userInfo['menu'] = (new Login(App()))->getAccessMenuData($userInfo['id']);
|
||||||
|
|
||||||
$apiAuth = md5(uniqid() . time());
|
$apiAuth = md5(uniqid() . time());
|
||||||
cache('Login:' . $apiAuth, json_encode($userInfo), config('apiadmin.ONLINE_TIME'));
|
cache('Login:' . $apiAuth, json_encode($userInfo), config('apiadmin.ONLINE_TIME'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user