From 1bcbbdaa68497ded1a3840acb614b263e6b3e581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E8=BE=B0=E8=BD=A9?= Date: Fri, 24 Jun 2022 10:29:04 +0800 Subject: [PATCH] * Login action are recorded by default. --- api/v1/entries/tokens.php | 7 ++++--- module/user/model.php | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/v1/entries/tokens.php b/api/v1/entries/tokens.php index a7e91194f1..b205d9d322 100644 --- a/api/v1/entries/tokens.php +++ b/api/v1/entries/tokens.php @@ -19,15 +19,16 @@ class tokensEntry extends baseEntry */ public function post() { - $account = $this->request('account'); - $password = $this->request('password'); + $account = $this->request('account'); + $password = $this->request('password'); + $addAction = $this->request('addAction', true); if($this->loadModel('user')->checkLocked($account)) return $this->sendError(400, sprintf($this->lang->user->loginLocked, $this->config->user->lockMinutes)); $user = $this->user->identify($account, $password); if($user) { - $this->user->login($user); + $this->user->login($user, $addAction); $this->send(201, array('token' => session_id())); } else diff --git a/module/user/model.php b/module/user/model.php index 87d50f4a38..77e2d0c486 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -1100,11 +1100,12 @@ class userModel extends model /** * login function. * - * @param object $user + * @param object $user + * @param bool $addAction * @access public * @return bool|object */ - public function login($user) + public function login($user, $addAction = true) { if(!$user) return false; @@ -1118,7 +1119,7 @@ class userModel extends model $this->session->set('user', $user); $this->app->user = $this->session->user; - if(isset($user->id)) $this->loadModel('action')->create('user', $user->id, 'login'); + if(isset($user->id) and $addAction) $this->loadModel('action')->create('user', $user->id, 'login'); $this->loadModel('score')->create('user', 'login'); /* Keep login. */