enable login notify

This commit is contained in:
xiaomlove
2023-04-09 02:33:37 +08:00
parent 2c85edb1b3
commit 4535ba94a4
6 changed files with 27 additions and 27 deletions

View File

@@ -13,6 +13,7 @@ use App\Models\ExamProgress;
use App\Models\ExamUser; use App\Models\ExamUser;
use App\Models\HitAndRun; use App\Models\HitAndRun;
use App\Models\Invite; use App\Models\Invite;
use App\Models\LoginLog;
use App\Models\Medal; use App\Models\Medal;
use App\Models\Peer; use App\Models\Peer;
use App\Models\SearchBox; use App\Models\SearchBox;
@@ -96,26 +97,21 @@ class Test extends Command
*/ */
public function handle() public function handle()
{ {
$rep = new MeiliSearchRepository(); $thisLoginLog = LoginLog::query()->findOrFail(10);
// $r = $rep->doImportFromDatabase(); $lastLoginLog = LoginLog::query()->findOrFail(9);
// dd($r); $user = User::query()->findOrFail(1, User::$commonFields);
// $r = $rep->import(); $locale = $user->locale;
$toolRep = new ToolRepository();
$r = $rep->search([ $subject = nexus_trans('message.login_notify.subject', ['site_name' => Setting::get('basic.SITENAME')], $locale);
'search' => '200', $body = nexus_trans('message.login_notify.body', [
'spstate' => 0, 'this_login_time' => $thisLoginLog->created_at,
'incldead' => 0, 'this_ip' => $thisLoginLog->ip,
'mode' => 4, 'this_location' => sprintf('%s·%s', $thisLoginLog->city, $thisLoginLog->country),
// 'cat401' => 1, 'last_login_time' => $lastLoginLog->created_at,
'sort' => '4', 'last_ip' => $lastLoginLog->ip,
'type' => 'desc', 'last_location' => sprintf('%s·%s', $lastLoginLog->city, $lastLoginLog->country),
'search_mode' => 0, ], $locale);
'inclbookmarked' => 0, dd($body);
'approval_status' => 1,
// 'size_end' => 20,
// 'added_end' => '2023-02-11',
], 1, 'incldead=0&spstate=1&inclbookmarked=0&approval_status=1&size_begin=&size_end=&seeders_begin=&seeders_end=&leechers_begin=&leechers_end=&times_completed_begin=&times_completed_end=&added_begin=&added_end=&search=200&search_area=0&search_mode=0');
dd($r);
} }
} }

View File

@@ -32,6 +32,10 @@ class UserLoginNotify extends Command
$thisId = $this->option('this_id'); $thisId = $this->option('this_id');
$lastId = $this->option('last_id'); $lastId = $this->option('last_id');
$this->info("thisId: $thisId, lastId: $lastId"); $this->info("thisId: $thisId, lastId: $lastId");
if (!$thisId || !$lastId) {
$this->error("require option --this_id=? and --last_id=?");
return Command::FAILURE;
}
SendLoginNotify::dispatch($thisId, $lastId); SendLoginNotify::dispatch($thisId, $lastId);
return Command::SUCCESS; return Command::SUCCESS;
} }

View File

@@ -53,7 +53,7 @@ if (
) { ) {
$command = sprintf("user:login_notify --this_id=%s --last_id=%s", $thisLoginLog->id, $lastLoginLog->id); $command = sprintf("user:login_notify --this_id=%s --last_id=%s", $thisLoginLog->id, $lastLoginLog->id);
do_log("[LOGIN_NOTIFY], user: {$row['id']}, $command"); do_log("[LOGIN_NOTIFY], user: {$row['id']}, $command");
// executeCommand($command, "string", true, false); executeCommand($command, "string", true, false);
} }
if ($row["enabled"] == "no") if ($row["enabled"] == "no")
bark($lang_takelogin['std_account_disabled']); bark($lang_takelogin['std_account_disabled']);

View File

@@ -34,8 +34,8 @@ return [
'login_notify' => [ 'login_notify' => [
'subject' => ':site_name Offsite login alert', 'subject' => ':site_name Offsite login alert',
'body' => <<<BODY 'body' => <<<BODY
You logged in at :this_login_time, IP::this_ip, location::this_location. You logged in at::this_login_time, IP::this_ip, location::this_location.<br/>
Last login time::last_login_time, IP::last_ip, location::last_location. Last login time::last_login_time, IP::last_ip, location::last_location.<br/>
If it is not your own operation, the account password may have been leaked, please change it in time! If it is not your own operation, the account password may have been leaked, please change it in time!
BODY, BODY,
], ],

View File

@@ -34,8 +34,8 @@ return [
'login_notify' => [ 'login_notify' => [
'subject' => ':site_name 异地登录提醒', 'subject' => ':site_name 异地登录提醒',
'body' => <<<BODY 'body' => <<<BODY
你于 :this_login_time 进行了登录操作IP:this_ip位置:this_location。 你于: :this_login_time 进行了登录操作IP:this_ip位置:this_location。<br/>
上次登录时间::last_login_timeIP:last_ip位置:last_location。 上次登录时间::last_login_timeIP:last_ip位置:last_location。<br/>
若不是你本人操作,账号密码可能已经泄露,请及时修改! 若不是你本人操作,账号密码可能已经泄露,请及时修改!
BODY, BODY,
], ],

View File

@@ -33,8 +33,8 @@ return [
'login_notify' => [ 'login_notify' => [
'subject' => ':site_name 異地登錄提醒', 'subject' => ':site_name 異地登錄提醒',
'body' => <<<BODY 'body' => <<<BODY
你於 :this_login_time 進行了登錄操作IP:this_ip位置:this_location。 你於:this_login_time 進行了登錄操作IP:this_ip位置:this_location。<br/>
上次登錄時間::last_login_timeIP:last_ip位置:last_location。 上次登錄時間::last_login_timeIP:last_ip位置:last_location。<br/>
若不是你本人操作,賬號密碼可能已經泄露,請及時修改! 若不是你本人操作,賬號密碼可能已經泄露,請及時修改!
BODY, BODY,
] ]