feat(reset_pw): email notification
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-05-02 18:28:59 +08:00
parent 8f3120c3f0
commit 147961a9b9
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 22 additions and 1 deletions

View File

@ -32,6 +32,27 @@ function resetPassword() {
$newPW = $_POST['newPW']; $newPW = $_POST['newPW'];
$newPW = getPasswordToStore($newPW, $user['username']); $newPW = getPasswordToStore($newPW, $user['username']);
$oj_name = UOJConfig::$data['profile']['oj-name'];
$oj_name_short = UOJConfig::$data['profile']['oj-name-short'];
$name = $user['username'];
$remote_addr = UOJContext::remoteAddr();
$http_x_forwarded_for = UOJContext::httpXForwardedFor();
$user_agent = UOJContext::httpUserAgent();
if ($user['realname']) {
$name .= ' (' . $user['realname'] . ')';
}
sendEmail($user['username'], "密码被重置", <<<EOD
<p>您刚刚重置了您在 {$oj_name_short} 上账号的密码。如果这是您进行的操作,请忽略本邮件。如果您没有请求重置密码,请立即联系管理员进行处理。</p>
<ul>
<li>请求 IP: {$remote_addr}</li>
<li>转发源 IP: {$http_x_forwarded_for} </li>
<li>用户代理: {$user_agent}</li>
</ul>
EOD, 5);
DB::update([ DB::update([
"update user_info", "update user_info",
"set", [ "set", [