mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
enable login notify
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Models\ExamProgress;
|
||||
use App\Models\ExamUser;
|
||||
use App\Models\HitAndRun;
|
||||
use App\Models\Invite;
|
||||
use App\Models\LoginLog;
|
||||
use App\Models\Medal;
|
||||
use App\Models\Peer;
|
||||
use App\Models\SearchBox;
|
||||
@@ -96,26 +97,21 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$rep = new MeiliSearchRepository();
|
||||
// $r = $rep->doImportFromDatabase();
|
||||
// dd($r);
|
||||
// $r = $rep->import();
|
||||
|
||||
$r = $rep->search([
|
||||
'search' => '200',
|
||||
'spstate' => 0,
|
||||
'incldead' => 0,
|
||||
'mode' => 4,
|
||||
// 'cat401' => 1,
|
||||
'sort' => '4',
|
||||
'type' => 'desc',
|
||||
'search_mode' => 0,
|
||||
'inclbookmarked' => 0,
|
||||
'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=×_completed_begin=×_completed_end=&added_begin=&added_end=&search=200&search_area=0&search_mode=0');
|
||||
dd($r);
|
||||
$thisLoginLog = LoginLog::query()->findOrFail(10);
|
||||
$lastLoginLog = LoginLog::query()->findOrFail(9);
|
||||
$user = User::query()->findOrFail(1, User::$commonFields);
|
||||
$locale = $user->locale;
|
||||
$toolRep = new ToolRepository();
|
||||
$subject = nexus_trans('message.login_notify.subject', ['site_name' => Setting::get('basic.SITENAME')], $locale);
|
||||
$body = nexus_trans('message.login_notify.body', [
|
||||
'this_login_time' => $thisLoginLog->created_at,
|
||||
'this_ip' => $thisLoginLog->ip,
|
||||
'this_location' => sprintf('%s·%s', $thisLoginLog->city, $thisLoginLog->country),
|
||||
'last_login_time' => $lastLoginLog->created_at,
|
||||
'last_ip' => $lastLoginLog->ip,
|
||||
'last_location' => sprintf('%s·%s', $lastLoginLog->city, $lastLoginLog->country),
|
||||
], $locale);
|
||||
dd($body);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@ class UserLoginNotify extends Command
|
||||
$thisId = $this->option('this_id');
|
||||
$lastId = $this->option('last_id');
|
||||
$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);
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ if (
|
||||
) {
|
||||
$command = sprintf("user:login_notify --this_id=%s --last_id=%s", $thisLoginLog->id, $lastLoginLog->id);
|
||||
do_log("[LOGIN_NOTIFY], user: {$row['id']}, $command");
|
||||
// executeCommand($command, "string", true, false);
|
||||
executeCommand($command, "string", true, false);
|
||||
}
|
||||
if ($row["enabled"] == "no")
|
||||
bark($lang_takelogin['std_account_disabled']);
|
||||
|
||||
@@ -34,8 +34,8 @@ return [
|
||||
'login_notify' => [
|
||||
'subject' => ':site_name Offsite login alert',
|
||||
'body' => <<<BODY
|
||||
You logged in at :this_login_time, IP::this_ip, location::this_location.
|
||||
Last login time::last_login_time, IP::last_ip, location::last_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.<br/>
|
||||
If it is not your own operation, the account password may have been leaked, please change it in time!
|
||||
BODY,
|
||||
],
|
||||
|
||||
@@ -34,8 +34,8 @@ return [
|
||||
'login_notify' => [
|
||||
'subject' => ':site_name 异地登录提醒',
|
||||
'body' => <<<BODY
|
||||
你于 :this_login_time 进行了登录操作,IP::this_ip,位置::this_location。
|
||||
上次登录时间::last_login_time,IP::last_ip,位置::last_location。
|
||||
你于: :this_login_time 进行了登录操作。IP::this_ip,位置::this_location。<br/>
|
||||
上次登录时间::last_login_time,IP::last_ip,位置::last_location。<br/>
|
||||
若不是你本人操作,账号密码可能已经泄露,请及时修改!
|
||||
BODY,
|
||||
],
|
||||
|
||||
@@ -33,8 +33,8 @@ return [
|
||||
'login_notify' => [
|
||||
'subject' => ':site_name 異地登錄提醒',
|
||||
'body' => <<<BODY
|
||||
你於 :this_login_time 進行了登錄操作,IP::this_ip,位置::this_location。
|
||||
上次登錄時間::last_login_time,IP::last_ip,位置::last_location。
|
||||
你於::this_login_time 進行了登錄操作,IP::this_ip,位置::this_location。<br/>
|
||||
上次登錄時間::last_login_time,IP::last_ip,位置::last_location。<br/>
|
||||
若不是你本人操作,賬號密碼可能已經泄露,請及時修改!
|
||||
BODY,
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user