forked from ticketfrei/ticketfrei
catch some error cases.
This commit is contained in:
parent
9339015101
commit
4981223ee8
35
frontend.py
35
frontend.py
|
@ -27,16 +27,19 @@ def register_post():
|
||||||
if db.by_email(email):
|
if db.by_email(email):
|
||||||
return dict(error='Email address already in use.')
|
return dict(error='Email address already in use.')
|
||||||
# send confirmation mail
|
# send confirmation mail
|
||||||
sendmail(
|
try:
|
||||||
email,
|
sendmail(
|
||||||
"[Ticketfrei] Confirm your account",
|
email,
|
||||||
"Complete your registration here: %s://%s/confirm/%s" % (
|
"[Ticketfrei] Confirm your account",
|
||||||
request.urlparts.scheme,
|
"Complete your registration here: %s://%s/confirm/%s" % (
|
||||||
request.urlparts.netloc,
|
request.urlparts.scheme,
|
||||||
db.user_token(email, password)
|
request.urlparts.netloc,
|
||||||
)
|
db.user_token(email, password)
|
||||||
)
|
)
|
||||||
return dict(info='Confirmation mail sent.')
|
)
|
||||||
|
return dict(info='Confirmation mail sent.')
|
||||||
|
except Exception:
|
||||||
|
return dict(error='Could not send confirmation mail.')
|
||||||
|
|
||||||
|
|
||||||
@get('/confirm/<token>')
|
@get('/confirm/<token>')
|
||||||
|
@ -53,10 +56,14 @@ def confirm(token):
|
||||||
@view('template/login.tpl')
|
@view('template/login.tpl')
|
||||||
def login_post():
|
def login_post():
|
||||||
# check login
|
# check login
|
||||||
if db.by_email(request.forms.get('email', '')) \
|
try:
|
||||||
.check_password(request.forms.get('pass', '')):
|
if db.by_email(request.forms.get('email', '')) \
|
||||||
return redirect('/settings')
|
.check_password(request.forms.get('pass', '')):
|
||||||
return dict(error='Authentication failed.')
|
return redirect('/settings')
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
return dict(error='Authentication failed.')
|
||||||
|
|
||||||
|
|
||||||
@get('/settings')
|
@get('/settings')
|
||||||
|
|
Loading…
Reference in a new issue