API: Added A Skeleton Route For Email Validation

This commit is contained in:
Sagi Dayan 2015-06-11 21:32:46 +03:00
parent 7edd66ff70
commit f31053f632
2 changed files with 30 additions and 6 deletions

View file

@ -43,7 +43,29 @@ def page_not_found(e):
def wellcomePage():
return app.send_static_file('index.html')
@app.route('/api/validatation/sendmail/<string:token>', methods=['POST'])
@app.route('/api/validation/confirm/<string:validation_token>')
@auto.doc()
def confirm_user_to_campus(validation_token):
"""
This Function is will re
:param validation_token: 'seToken|email_suffix'
:return:
200 - redirect to home + new cookie
403 - Invalid Token
"""
#TODO
token = str(validation_token).split('|')[0]
email_sufix = '@'+str(validation_token).split('|')[1]
if is_user_token_valid(token):
return Response(status=200, response=json.dumps({'token': token, 'suffix': email_sufix}))
else:
return Response(response=json.dumps({'message': 'Not A Valid Token!'}),
status=403,
mimetype="application/json")
@app.route('/api/validation/sendmail/<string:token>', methods=['POST'])
@auto.doc()
def send_activation(token):
"""
@ -146,7 +168,7 @@ def oauth(oauth_token):
else:
tempEmail = user_data["email"]
user = User(username=user_data["login"], name=tempName, avatar_url=user_data["avatar_url"], email=tempEmail, isLecturer=False, accsessToken=oauth_token, seToken=str(uuid.uuid4()))
user = User(username=user_data["login"], name=tempName, avatar_url=user_data["avatar_url"], email=tempEmail, isLecturer=False, accessToken=oauth_token, seToken=str(uuid.uuid4()))
db.put(user)
db.save
return cookieMonster(user.seToken)

View file

@ -13,8 +13,9 @@ def is_user_token_valid(token):
return False
def send_validation_email(token, email, name):
emailSuffix = str(email).split('@')[1]
message = mail.EmailMessage(sender="SE-Hub Support <se-hub@appspot.gserviceaccount.com>",
subject="SE-Hub Activate Account")
subject="SE-Hub Activate Account")
message.to = email
@ -22,8 +23,8 @@ def send_validation_email(token, email, name):
Dear """+name+""":
To Activate your SE-Hub Account please click on the link below:<br>
http://se-hub.appspot.com/api/validatation/confirm/"""+token+"""
to access you virtual class.
http://se-hub.appspot.com/api/validation/confirm/"""+token+"""|"""+emailSuffix+"""
to get access to your Campus :)
Please let us know if you have any questions.
@ -35,6 +36,7 @@ def send_validation_email(token, email, name):
<div>
<center>
<img src='https://cloud.githubusercontent.com/assets/2984053/6825467/7c9d0402-d303-11e4-9827-62a6d66f937a.png'>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
</center>
</div>
<div style='width:70%'>
@ -42,7 +44,7 @@ def send_validation_email(token, email, name):
<h3>Dear """+name+""":</h3>
To Activate your SE-Hub Account please click on the link below:<br>
http://se-hub.appspot.com/api/validatation/confirm/"""+token+"""<br><br>
http://se-hub.appspot.com/api/validation/confirm/"""+token+"""|"""+emailSuffix+"""
to access you virtual class.
</div>