login check with cookies works now. fixed some layout stuff

This commit is contained in:
b3yond 2018-02-16 17:46:43 +01:00
parent 1b75e03fc5
commit a7bae0aed9
5 changed files with 27 additions and 6 deletions

View file

@ -49,8 +49,8 @@ def login():
except TypeError:
return "Wrong Credentials." # no user with this email
if pylibscrypt.scrypt_mcf_check(pass_hashed, psw):
# :todo Generate Session Cookie and give to user
return bottle.static_file("../static/bot.html", root="../static")
bottle.response.set_cookie("account", uname, secret)
return bottle.redirect("/settings")
else:
return "Wrong Credentials." # passphrase is wrong
@ -106,7 +106,21 @@ def confirmaccount(encoded_jwt):
# create db entry
db.cur.execute("INSERT INTO user(email, pass_hashed, enabled) VALUES(?, ?, ?);", (uname, pass_hashed, True))
db.conn.commit()
bottle.response.set_cookie("account", uname, secret)
return bottle.redirect("/settings")
@app.route('/settings')
def manage_bot():
"""
Restricted area. Deliver the bot settings page.
:return:
"""
uname = bottle.request.get_cookie("account", secret=secret)
if uname is not None:
return bottle.static_file("../static/bot.html", root='../static')
else:
bottle.abort(401, "Sorry, access denied.")
@app.route('/static/<filename:path>')

View file

@ -4,7 +4,7 @@
</head>
<body style="background-image: url(/static/img/wallpaper.png)">
<div class="area">
<h1><a href="https://ticketfrei.links-tech.org"><img src="/static/img/ticketfrei_logo.png" alt="Ticketfrei" height="150px" align="center" style="float: none;"></a></h1>
<h1><a href="/"><img src="/static/img/ticketfrei_logo.png" alt="Ticketfrei" height="150px" align="center" style="float: none;"></a></h1>
# Is the user logged in? else, complain & show nothing.

View file

@ -12,6 +12,8 @@ body {
margin-left: auto;
margin-right: auto;
text-align: center;
min-height: 100%;
position: relative;
}
.text {
@ -61,4 +63,8 @@ input[type=text], input[type=password] {
.footer {
padding: 2em;
position: absolute;
bottom: 0;
text-align: center;
width: 540px;
}

View file

@ -5,7 +5,7 @@
<body style="background-image: url(static/img/wallpaper.png)">
<div class="area">
<h1><a href="https://ticketfrei.links-tech.org"><img src="/static/img/ticketfrei_logo.png" alt="Ticketfrei" height="150px" align="center" style="float: none;"></a></h1>
<h1><a href="/"><img src="/static/img/ticketfrei_logo.png" alt="Ticketfrei" height="150px" align="center" style="float: none;"></a></h1>
<form action="../login" method="POST">
<div class="container">
@ -68,6 +68,7 @@
popular during the Renaissance. The first line of Lorem
Ipsum, "Lorem ipsum dolor sit amet..", comes from a line
in section 1.10.32.</p>
<br>
</div>
<div class=footer>
Contribute on <a href="https://github.com/b3yond/ticketfrei">GitHub!</a>

View file

@ -5,7 +5,7 @@
<body style="background-image: url(img/wallpaper.png)">
<div class="area">
<h1><a href="https://ticketfrei.links-tech.org"><img src="/static/img/ticketfrei_logo.png" alt="Ticketfrei" height="150px" align="center" style="float: none;"></a></h1>
<h1><a href="/"><img src="/static/img/ticketfrei_logo.png" alt="Ticketfrei" height="150px" align="center" style="float: none;"></a></h1>
<form action="../register" method="post">
<div class="container">
<label><b>Email</b></label>