Skip to content

Commit

Permalink
feat small: verification mail failure message
Browse files Browse the repository at this point in the history
  • Loading branch information
elpwc committed Jul 19, 2024
1 parent afe6ed4 commit b00dbf9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
7 changes: 6 additions & 1 deletion public/api/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@

$_SESSION["verify_code"] = $verify_code;

send_verification_mail($email, $verify_code);
$res = send_verification_mail($email, $verify_code);

if ($res) {
echo json_encode(["res" => "ok"]);
} else {
echo json_encode(["res" => "fail"]);
}

break;
default:
Expand Down
4 changes: 2 additions & 2 deletions public/api/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ function send_verification_mail($target, $verify_code)
"老头环地图 邮箱验证码",
'<h3>验证码是:<span>' . $verify_code . '</span></h3><p>有效期:5分钟</p>' . date('Y-m-d H:i:s')
);
echo $mail->send();
return true;
} catch (Exception $e) {
echo 'failed';
return false;
}
}
19 changes: 10 additions & 9 deletions src/components/MapView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2047,22 +2047,23 @@
.then(res => {
switch (res.data.res) {
case 'ok':
register_error = $t('map.modals.register.verification_code_send');
countdown_for_verification_code = 60;
const countdown_verification_timer = setInterval(() => {
countdown_for_verification_code--;
if (countdown_for_verification_code <= 0) {
clearTimeout(countdown_verification_timer);
}
}, 1000);
break;
case 'fail':
register_error = $t('map.modals.register.verification_code_send_fail');
break;
default:
console.log(res)
console.log(res);
break;
}
});

countdown_for_verification_code = 60;
const countdown_verification_timer = setInterval(() => {
countdown_for_verification_code--;
if (countdown_for_verification_code <= 0) {
clearTimeout(countdown_verification_timer);
}
}, 1000);
}}
disabled={countdown_for_verification_code > 0}
>
Expand Down
1 change: 1 addition & 0 deletions src/locale/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const lang = {
verification_code_blank: '邮箱验证码还沒有输入哦',
verification_code_error: '邮箱验证码不正确哦',
verification_code_send: '已发送, 如果没有收到请检查垃圾邮件',
verification_code_send_fail: '邮件发送失败,请检查邮箱是否有问题',
},
login: {
title: '登录',
Expand Down
1 change: 1 addition & 0 deletions src/locale/lang/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const lang = {
verification_code_blank: '邮箱验证码还沒有输入哦',
verification_code_error: '邮箱验证码不正确哦',
verification_code_send: '已发送, 如果没有收到请检查垃圾邮件',
verification_code_send_fail: '邮件发送失败,请检查邮箱是否有问题',
},
login: {
title: '登录',
Expand Down
1 change: 1 addition & 0 deletions src/locale/lang/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const lang: langType = {
verification_code_blank: '邮箱验证码还沒有输入哦',
verification_code_error: '邮箱验证码不正确哦',
verification_code_send: '已发送, 如果没有收到请检查垃圾邮件',
verification_code_send_fail: '邮件发送失败,请检查邮箱是否有问题',
},
login: {
title: '登入',
Expand Down

0 comments on commit b00dbf9

Please sign in to comment.