refactor(reset_pw): bootstrap5

This commit is contained in:
Baoshuo Ren 2023-02-05 20:36:06 +08:00
parent c115329147
commit 35c77868aa
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
3 changed files with 32 additions and 18 deletions

View File

@ -1,4 +1,8 @@
<?php <?php
requireLib('bootstrap5');
requireLib('dialog');
requireLib('md5');
if (!isset($_GET['p'])) { if (!isset($_GET['p'])) {
become404Page(); become404Page();
} }
@ -46,24 +50,30 @@ if (isset($_POST['reset'])) {
die(resetPassword()); die(resetPassword());
} }
?> ?>
<?php
$REQUIRE_LIB['dialog'] = ''; <?php echoUOJPageHeader(UOJLocale::get('reset password')) ?>
$REQUIRE_LIB['md5'] = '';
?> <form id="form-reset" class="card mw-100 mx-auto" style="width:600px">
<?php echoUOJPageHeader('更改密码') ?> <div class="card-body">
<h2 class="page-header">更改密码</h2> <h1 class="card-title text-center mb-3">
<form id="form-reset" class="form-horizontal"> <?= UOJLocale::get('reset password') ?>
<div id="div-password" class="form-group"> </h1>
<label for="input-password" class="col-sm-2 control-label">新密码</label> <div class="mb-1">
<div class="col-sm-3"> <label for="input-username" class="form-label"><?= UOJLocale::get('username') ?></label>
<input type="password" class="form-control" id="input-password" name="password" placeholder="输入新密码" maxlength="20" /> <input type="text" class="form-control" value="<?= $user['username'] ?>" disabled />
<input type="password" class="form-control top-buffer-sm" id="input-confirm_password" placeholder="再次输入新密码" maxlength="20" />
<span class="help-block" id="help-password"></span>
</div> </div>
<div id="div-password" class="mb-1">
<label for="input-password" class="form-label">
<?= UOJLocale::get('new password') ?>
</label>
<input type="password" class="form-control" id="input-password" name="password" placeholder="<?= UOJLocale::get('enter your password') ?>" maxlength="20" />
<input type="password" class="form-control mt-2" id="input-confirm_password" placeholder="<?= UOJLocale::get('re-enter your password') ?>" maxlength="20" />
<span class="help-block invalid-feedback" id="help-password"></span>
</div> </div>
<div class="form-group"> <div class="text-center">
<div class="col-sm-offset-2 col-sm-3"> <button type="submit" id="button-submit" class="btn btn-primary">
<button type="submit" id="button-submit" class="btn btn-secondary">提交</button> <?= UOJLocale::get('submit') ?>
</button>
</div> </div>
</div> </div>
</form> </form>
@ -74,12 +84,13 @@ $REQUIRE_LIB['md5'] = '';
ok &= getFormErrorAndShowHelp('password', validateSettingPassword); ok &= getFormErrorAndShowHelp('password', validateSettingPassword);
return ok; return ok;
} }
$(document).ready(function() { $(document).ready(function() {
$('#form-reset').submit(function(e) { $('#form-reset').submit(function(e) {
if (!validateResetPwPost()) { if (!validateResetPwPost()) {
return false; return false;
} }
$.post(<?= json_encode($_SERVER['REQUEST_URI']) ?>, { $.post(<?= json_encode(UOJContext::requestURI()) ?>, {
reset: '', reset: '',
newPW: md5($('#input-password').val(), "<?= getPasswordClientSalt() ?>") newPW: md5($('#input-password').val(), "<?= getPasswordClientSalt() ?>")
}, function(res) { }, function(res) {
@ -116,4 +127,5 @@ $REQUIRE_LIB['md5'] = '';
}); });
}); });
</script> </script>
<?php echoUOJPageFooter() ?> <?php echoUOJPageFooter() ?>

View File

@ -39,6 +39,7 @@ return [
'new password' => 'New password', 'new password' => 'New password',
'current password' => 'Current password', 'current password' => 'Current password',
'confirm new password' => 'Confirm new password', 'confirm new password' => 'Confirm new password',
'reset password' => 'Reset Password',
'verification code' => 'Verification code', 'verification code' => 'Verification code',
'email' => 'Email', 'email' => 'Email',
'QQ' => 'QQ', 'QQ' => 'QQ',

View File

@ -39,6 +39,7 @@ return [
'new password' => '新密码', 'new password' => '新密码',
'current password' => '当前密码', 'current password' => '当前密码',
'confirm new password' => '确认新密码', 'confirm new password' => '确认新密码',
'reset password' => '重置密码',
'verification code' => '验证码', 'verification code' => '验证码',
'email' => 'Email', 'email' => 'Email',
'QQ' => 'QQ', 'QQ' => 'QQ',