1
0
Fork 0

修改Bug505,并重写reset.html,抽离共同样式

Bug505-ZhangYiteng
张艺腾 2022-12-03 12:20:54 +08:00
parent 671df67723
commit b7500646c2
5 changed files with 139 additions and 233 deletions

View File

@ -112,6 +112,13 @@ def reset():
# POST请求用于提交修改后信息 # POST请求用于提交修改后信息
old_password = escape(request.form['old-password']) old_password = escape(request.form['old-password'])
new_password = escape(request.form['new-password']) new_password = escape(request.form['new-password'])
re_new_password = escape(request.form['re-new-password']) # 确认新密码
if re_new_password != new_password: #验证新密码两次输入是否相同
return '新密码不匹配,请重新输入'
if len(new_password) < 4: #验证新密码长度,原则参照注册模块
return '密码过于简单。(密码长度至少4位)'
flag = change_password(username, old_password, new_password) # flag表示是否修改成功 flag = change_password(username, old_password, new_password) # flag表示是否修改成功
if flag: if flag:
session['logged_in'] = False session['logged_in'] = False

View File

@ -0,0 +1,107 @@
/*样式应用于login、signup、reset三个页面*/
.container {
background-color: #FFFFFF;
width: 400px;
height: 500px;
margin: 7em auto;
border-radius: 1.5em;
box-shadow: 0px 11px 35px 2px rgba(0, 0, 0, 0.14);
}
/*增加一个类reset-heading*/
.signin-heading, .reset-heading {
padding-top: 5px;
color: #8C55AA;
font-family: 'Ubuntu', sans-serif;
font-weight: bold;
font-size: 23px;
text-align: center;
}
/*增加2个类.old-password和.new-password*/
.username, .email, .password, .re-password, .old-password, .new-password,.re-new-password {
width: 76%;
color: rgb(38, 50, 56);
font-weight: 700;
font-size: 14px;
letter-spacing: 1px;
background: rgba(136, 126, 126, 0.04);
padding: 10px 20px;
border: none;
border-radius: 20px;
outline: none;
box-sizing: border-box;
border: 2px solid rgba(124, 16, 97, 0.02);
margin-bottom: 50px;
margin-left: 46px;
text-align: center;
margin-bottom: 27px;
font-family: 'Ubuntu', sans-serif;
}
.btn {
width: 50%;
border: none;
border-radius: 20px;
box-sizing: border-box;
border: 2px solid #8C55AA;
margin-bottom: 50px;
margin-left: 90px;
padding: 10px 20px;
}
.btn:hover {
background: #8C55AA;
transition: .5s;
cursor: pointer;
color: #fff;
}
.signup {
display: flex;
justify-content: center;
align-items: center;
}
ul {
position: absolute;
display: flex;
left: 65%;
}
li {
padding: 10px;
margin: 10px;
}
a {
text-decoration: none;
list-style: none;
font-weight: bold;
font-family: 'ink free';
}
.main_menu a {
color: #fff;
font-size: 300px;
}
li :hover {
color: #8C55AA;
transition: .5s;
}
h1 {
font-family: 'ink free';
}
.main_menu h1 {
color: #fff;
}

View File

@ -5,115 +5,7 @@ You're logged in already!
{% else %} {% else %}
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" /> <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" />
<style> <link rel="stylesheet" href="static/css/login_service.css">
.container{
background-color: #FFFFFF;
width: 400px;
height: 500px;
margin: 7em auto;
border-radius: 1.5em;
box-shadow: 0px 11px 35px 2px rgba(0, 0, 0, 0.14);
}
.signin-heading{
padding-top: 5px;
color: #8C55AA;
font-family: 'Ubuntu', sans-serif;
font-weight: bold;
font-size: 23px;
text-align: center;
}
.username, .email, .password, .re-password{
width: 76%;
color: rgb(38, 50, 56);
font-weight: 700;
font-size: 14px;
letter-spacing: 1px;
background: rgba(136, 126, 126, 0.04);
padding: 10px 20px;
border: none;
border-radius: 20px;
outline: none;
box-sizing: border-box;
border: 2px solid rgba(124, 16, 97, 0.02);
margin-bottom: 50px;
margin-left: 46px;
text-align: center;
margin-bottom: 27px;
font-family: 'Ubuntu', sans-serif;
}
.btn{
width: 50%;
border: none;
border-radius: 20px;
box-sizing: border-box;
border: 2px solid #8C55AA;
margin-bottom: 50px;
margin-left: 90px;
padding: 10px 20px;
}
.btn:hover{
background: #8C55AA;
transition: .5s;
cursor: pointer;
color: #fff;
}
.signup{
display: flex;
justify-content: center;
align-items: center;
}
ul{
position: absolute;
display: flex;
left: 65%;
}
li{
padding: 10px;
margin: 10px;
}
a{
text-decoration: none;
list-style: none;
font-weight: bold;
font-family: 'ink free';
}
.main_menu a{
color: #fff;
font-size: 300;
}
li :hover{
color: #8C55AA;
transition: .5s;
}
h1{
font-family: 'ink free';
}
.main_menu h1{
color: #fff;
}
</style>
<div class="container"> <div class="container">

View File

@ -1,14 +1,22 @@
<html> {% block body %}
<body> <meta charset="utf-8" name="viewport"
<form action="/reset" method='POST'> content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes"/>
旧密码: <link rel="stylesheet" href="static/css/login_service.css">
<input type="password" name="old-password" />
<br/> <div class="container">
新密码:
<input type="password" name="new-password" /> <section class="reset-heading">
<br/> <h1>Reset Password</h1>
<input type="submit" name="submit" value="提交" /> </section>
<input type="button" name="submit" value="放弃修改" onclick="window.location.href='/{{ username }}'"/>
<form action="/reset" method="POST">
<input type="password" placeholder="原密码" class="old-password" name="old-password" required>
<input type="password" placeholder="新密码" class="new-password" name="new-password" required>
<input type="password" placeholder="确认新密码" class="re-new-password" name="re-new-password" required>
<input type="submit" name="submit" class="btn" value="提交"/>
<input type="button" name="submit" class="btn" value="放弃修改"
onclick="window.location.href='/{{ username }}'"/>
</form> </form>
</body>
</html> </div>
{% endblock %}

View File

@ -5,117 +5,9 @@ You're logged in already! <a href="/logout">Logout</a>.
{% else %} {% else %}
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" />
<p>{{ get_flashed_messages()[0] | safe }}</p> <link rel="stylesheet" href="static/css/login_service.css">
<p>{{ get_flashed_messages()[0] | safe }}</p>
<style>
.container{
background-color: #FFFFFF;
width: 400px;
height: 500px;
margin: 7em auto;
border-radius: 1.5em;
box-shadow: 0px 11px 35px 2px rgba(0, 0, 0, 0.14);
}
.signin-heading{
padding-top: 5px;
color: #8C55AA;
font-family: 'Ubuntu', sans-serif;
font-weight: bold;
font-size: 23px;
text-align: center;
}
.username,.password, .re-password{
width: 76%;
color: rgb(38, 50, 56);
font-weight: 700;
font-size: 14px;
letter-spacing: 1px;
background: rgba(136, 126, 126, 0.04);
padding: 10px 20px;
border: none;
border-radius: 20px;
outline: none;
box-sizing: border-box;
border: 2px solid rgba(124, 16, 97, 0.02);
margin-bottom: 50px;
margin-left: 46px;
text-align: center;
margin-bottom: 27px;
font-family: 'Ubuntu', sans-serif;
}
.btn{
width: 50%;
border: none;
border-radius: 20px;
box-sizing: border-box;
border: 2px solid #8C55AA;
margin-bottom: 50px;
margin-left: 90px;
padding: 10px 20px;
}
.btn:hover{
background: #8C55AA;
transition: .5s;
cursor: pointer;
color: #fff;
}
.signup{
display: flex;
justify-content: center;
align-items: center;
}
ul{
position: absolute;
display: flex;
left: 65%;
}
li{
padding: 10px;
margin: 10px;
}
a{
text-decoration: none;
list-style: none;
font-weight: bold;
font-family: 'ink free';
}
.main_menu a{
color: #fff;
font-size: 300;
}
li :hover{
color: #8C55AA;
transition: .5s;
}
h1{
font-family: 'ink free';
}
.main_menu h1{
color: #fff;
}
</style>
<div class="container"> <div class="container">