Merge branch 'multi-deployment' of dl6tom.de:public/ticketfrei into multi-deployment
This commit is contained in:
commit
064ca181c0
4
db.py
4
db.py
|
@ -137,6 +137,10 @@ class DB(object):
|
||||||
self.execute("INSERT INTO user (passhash) VALUES(?);",
|
self.execute("INSERT INTO user (passhash) VALUES(?);",
|
||||||
(json['passhash'], ))
|
(json['passhash'], ))
|
||||||
uid = self.cur.lastrowid
|
uid = self.cur.lastrowid
|
||||||
|
self.execute("""
|
||||||
|
INSERT INTO triggerpatterns (user_id, pattern)
|
||||||
|
VALUES(?, ?);
|
||||||
|
""", (uid, '.*'))
|
||||||
else:
|
else:
|
||||||
uid = json['uid']
|
uid = json['uid']
|
||||||
self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
|
self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
|
||||||
|
|
25
frontend.py
25
frontend.py
|
@ -26,9 +26,12 @@ def propaganda():
|
||||||
@post('/register')
|
@post('/register')
|
||||||
@view('template/register.tpl')
|
@view('template/register.tpl')
|
||||||
def register_post():
|
def register_post():
|
||||||
email = request.forms.get('email', '')
|
try:
|
||||||
password = request.forms.get('pass', '')
|
email = request.forms['email']
|
||||||
password_repeat = request.forms.get('pass-repeat', '')
|
password = request.forms['pass']
|
||||||
|
password_repeat = request.forms['pass-repeat']
|
||||||
|
except KeyError:
|
||||||
|
return dict(error='Please, fill the form.')
|
||||||
if password != password_repeat:
|
if password != password_repeat:
|
||||||
return dict(error='Passwords do not match.')
|
return dict(error='Passwords do not match.')
|
||||||
if db.by_email(email):
|
if db.by_email(email):
|
||||||
|
@ -54,7 +57,7 @@ def confirm(token):
|
||||||
# create db-entry
|
# create db-entry
|
||||||
if db.confirm(token):
|
if db.confirm(token):
|
||||||
# :todo show info "Account creation successful."
|
# :todo show info "Account creation successful."
|
||||||
return redirect('/settings')
|
redirect('/settings')
|
||||||
return dict(error='Email confirmation failed.')
|
return dict(error='Email confirmation failed.')
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,9 +66,11 @@ def confirm(token):
|
||||||
def login_post():
|
def login_post():
|
||||||
# check login
|
# check login
|
||||||
try:
|
try:
|
||||||
if db.by_email(request.forms.get('email', '')) \
|
if db.by_email(request.forms['email']) \
|
||||||
.check_password(request.forms.get('pass', '')):
|
.check_password(request.forms['pass']):
|
||||||
return redirect('/settings')
|
redirect('/settings')
|
||||||
|
except KeyError:
|
||||||
|
return dict(error='Please, fill the form.')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
return dict(error='Authentication failed.')
|
return dict(error='Authentication failed.')
|
||||||
|
@ -92,7 +97,7 @@ def logout():
|
||||||
# clear auth cookie
|
# clear auth cookie
|
||||||
response.set_cookie('uid', '', expires=0, path="/")
|
response.set_cookie('uid', '', expires=0, path="/")
|
||||||
# :todo show info "Logout successful."
|
# :todo show info "Logout successful."
|
||||||
return redirect('/')
|
redirect('/')
|
||||||
|
|
||||||
|
|
||||||
@get('/login/twitter')
|
@get('/login/twitter')
|
||||||
|
@ -112,7 +117,7 @@ def login_twitter(user):
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
return dict(error="Failed to get request token.")
|
return dict(error="Failed to get request token.")
|
||||||
user.save_request_token(auth.request_token)
|
user.save_request_token(auth.request_token)
|
||||||
return bottle.redirect(redirect_url)
|
redirect(redirect_url)
|
||||||
|
|
||||||
|
|
||||||
@get('/login/twitter/callback')
|
@get('/login/twitter/callback')
|
||||||
|
@ -130,7 +135,7 @@ def twitter_callback(user):
|
||||||
auth.request_token = request_token
|
auth.request_token = request_token
|
||||||
auth.get_access_token(verifier)
|
auth.get_access_token(verifier)
|
||||||
user.save_twitter_token(auth.access_token, auth.access_token_secret)
|
user.save_twitter_token(auth.access_token, auth.access_token_secret)
|
||||||
return bottle.redirect("/settings")
|
redirect("/settings")
|
||||||
|
|
||||||
|
|
||||||
@post('/login/mastodon')
|
@post('/login/mastodon')
|
||||||
|
|
Loading…
Reference in a new issue