|
@@ -14,6 +14,7 @@ namespace app\index\controller;
|
|
|
|
|
|
use app\common\model\User as UserAlias;
|
|
|
use app\index\model\User as UserModel;
|
|
|
+use app\index\model\user\UserAccessLog;
|
|
|
use think\facade\Cache;
|
|
|
use app\index\service\passport\Login as LoginService;
|
|
|
use think\facade\Session;
|
|
@@ -37,6 +38,15 @@ class Passport extends Controller
|
|
|
public function login()
|
|
|
{
|
|
|
if ($this->request->method() == 'GET') {
|
|
|
+ UserAccessLog::doSave([
|
|
|
+ 'user_id' => 0,
|
|
|
+ 'path' => $this->request->action(),
|
|
|
+ 'remark' => '',
|
|
|
+ 'ip' => $this->request->ip(),
|
|
|
+ 'store_id' => $this->getStoreId(),
|
|
|
+ 'create_time' => time()
|
|
|
+ ]);
|
|
|
+
|
|
|
return view('logIn');
|
|
|
}
|
|
|
// 执行登录
|
|
@@ -51,7 +61,7 @@ class Passport extends Controller
|
|
|
Session::set('access_token', $token);
|
|
|
Session::set('user_id', $userInfo['user_id']);
|
|
|
|
|
|
- $returnUri = Session::pull('returnuri');
|
|
|
+ $returnUri = Session::pull('returnuri');
|
|
|
return $this->renderSuccess([
|
|
|
'userId' => (int)$userInfo['user_id'],
|
|
|
'token' => $LoginService->getToken((int)$userInfo['user_id']),
|
|
@@ -61,13 +71,22 @@ class Passport extends Controller
|
|
|
|
|
|
public function register()
|
|
|
{
|
|
|
+ $form = $this->postForm();
|
|
|
+ UserAccessLog::doSave([
|
|
|
+ 'user_id' => 0,
|
|
|
+ 'path' => $this->request->action(),
|
|
|
+ 'remark' => json_encode($form),
|
|
|
+ 'ip' => $this->request->ip(),
|
|
|
+ 'store_id' => $this->getStoreId(),
|
|
|
+ 'create_time' => time()
|
|
|
+ ]);
|
|
|
+
|
|
|
// 执行登录
|
|
|
$LoginService = new LoginService;
|
|
|
- if (!$LoginService->toRegister($this->postForm())) {
|
|
|
+ if (!$LoginService->toRegister($form)) {
|
|
|
return $this->renderError($LoginService->getError());
|
|
|
}
|
|
|
- $form = $this->postForm();
|
|
|
- if (!empty($form['mobile'])){
|
|
|
+ if (!empty($form['mobile'])) {
|
|
|
$userInfo = $LoginService->getUserInfo();
|
|
|
UserModel::setIncPoints(intval($userInfo['user_id']), UserAlias::POINTS_FOR_REGISTER, 'Register .');
|
|
|
}
|