1
0

small changes

This commit is contained in:
david 2016-11-10 00:43:06 +01:00
parent 7b6ce86af4
commit dce80a929b
5 changed files with 35 additions and 12 deletions

13
app.py
View File

@ -66,7 +66,8 @@ def login():
redirect('/')
else:
#render login page
return template('login', app_name=app_name, cookie_max_age=cookie_max_age)
message = request.get_cookie(cookie_name + "_message", secret=cookie_secret)
return template('login', app_name=app_name, cookie_max_age=cookie_max_age, message=message)
# get login credentials
@post('/login')
@ -74,7 +75,7 @@ def post_login():
username = request.forms.get('username')
password = request.forms.get('password')
if miab_auth(username, password):
message = { "message": "You have logged in successfully!", "alert": "success" }
message = { "message": "You have logged in successfully", "alert": "success" }
response.set_cookie(cookie_name + "_message", message, secret=cookie_secret, max_age=5)
redirect('/')
else:
@ -86,6 +87,8 @@ def post_login():
def logout():
if logged_in():
response.delete_cookie(cookie_name)
message = { "message": "You have logged out successfully", "alert": "success" }
response.set_cookie(cookie_name + "_message", message, secret=cookie_secret, max_age=5)
redirect('/')
else:
redirect('/')
@ -108,15 +111,15 @@ def post_password():
data = { "email": username, "password": newpassword }
a = requests.post(miab_url + "/mail/users/add", data=data, auth=(miab_admin, miab_passwd))
if r.status_code == 200 and a.status_code == 200:
message = { "message": "Your password has been changed successfully!", "alert": "primary" }
message = { "message": "Your password has been changed successfully", "alert": "success" }
response.set_cookie(cookie_name + "_message", message, secret=cookie_secret, max_age=5)
redirect('/')
else:
message = { "message": "Something went wrong while changing your password!", "alert": "danger" }
message = { "message": "Something went wrong while changing your password", "alert": "danger" }
response.set_cookie(cookie_name + "_message", message, secret=cookie_secret, max_age=5)
redirect('/')
else:
message = { "message": "Your supplied password is wrong!", "alert": "danger" }
message = { "message": "Your supplied password is wrong", "alert": "danger" }
response.set_cookie(cookie_name + "_message", message, secret=cookie_secret, max_age=5)
redirect('/')
else:

View File

@ -38,3 +38,9 @@ body {
border-top-left-radius: 0;
border-top-right-radius: 0;
}
@media (min-width: 600px) {
.container{
max-width: 600px;
}
}

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -63,12 +63,12 @@
<p>Enter your old password and your desired password and hit the change button.<br><small>Watch typos! I will not watch for you.</small></p>
<form class="form-inline" action="/password" method="post">
<div class="form-group">
<input name="oldpassword" type="password" class="form-control input-sm" id="changepasswordInput" placeholder="Old password">
<input name="oldpassword" type="password" class="form-control" id="changepasswordInput" placeholder="Old password">
</div>
<div class="form-group">
<input name="newpassword" type="password" class="form-control input-sm" id="changepasswordInput2" placeholder="New password">
<input name="newpassword" type="password" class="form-control" id="changepasswordInput2" placeholder="New password">
</div>
<button type="submit" class="btn btn-primary btn-sm">change</button>
<button type="submit" class="btn btn-primary">change</button>
</form>
@ -85,9 +85,9 @@
<form class="form-inline">
<div class="form-group">
<input type="email" class="form-control input-sm" id="ceatealiasInput" placeholder="alias@socialnerds.org">
<input type="email" class="form-control" id="ceatealiasInput" placeholder="alias@socialnerds.org">
</div>
<button type="submit" class="btn btn-primary btn-sm">create</button>
<button type="submit" class="btn btn-primary">create</button>
</form>
@ -100,9 +100,9 @@
<form class="form-inline">
<div class="form-group">
<input type="email" class="form-control input-sm" id="deleteaccountInput" placeholder="{{ username }}">
<input type="email" class="form-control" id="deleteaccountInput" placeholder="{{ username }}">
</div>
<button type="submit" class="btn btn-danger btn-sm">delete</button>
<button type="submit" class="btn btn-danger">delete</button>
</form>

View File

@ -21,6 +21,14 @@
<body>
<div class="container">
%if message:
<div class="alert alert-{{ message['alert'] }} alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{{ message['message'] }}.
</div>
%end
<form class="form-signin" action"/login" method="post">
<h2 class="form-signin-heading">SocialNerds Accounts<small>self-service login</small></h2>
<label for="inputEmail" class="sr-only">Email address</label>
@ -35,6 +43,12 @@
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/static/js/vendor/jquery.min.js"><\/script>')</script>
<script src="/static/js/bootstrap.min.js"></script>
</body>
</html>