added 2 methods (is_lecturer, get_user_by_token)
This commit is contained in:
parent
dcb83987f8
commit
628aad5e03
1 changed files with 15 additions and 2 deletions
|
@ -4,14 +4,27 @@ from models.User import User
|
||||||
from google.appengine.api import mail
|
from google.appengine.api import mail
|
||||||
|
|
||||||
|
|
||||||
def is_user_token_valid(token):
|
def get_user_by_token(token):
|
||||||
query = User.all()
|
query = User.all()
|
||||||
query.filter("seToken = ", token)
|
query.filter("seToken = ", token)
|
||||||
|
|
||||||
for u in query.run():
|
for u in query.run(limit = 1):
|
||||||
|
return u
|
||||||
|
return None
|
||||||
|
|
||||||
|
def is_user_token_valid(token):
|
||||||
|
user = get_user_by_token(token)
|
||||||
|
if user is not None:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_lecturer(token):
|
||||||
|
user = get_user_by_token(token)
|
||||||
|
if user is None:
|
||||||
|
return False
|
||||||
|
return user.isLecturer
|
||||||
|
|
||||||
|
|
||||||
def send_validation_email(token, email, name):
|
def send_validation_email(token, email, name):
|
||||||
message = mail.EmailMessage(sender="SE-Hub Support <se-hub@appspot.gserviceaccount.com>",
|
message = mail.EmailMessage(sender="SE-Hub Support <se-hub@appspot.gserviceaccount.com>",
|
||||||
subject="SE-Hub Activate Account")
|
subject="SE-Hub Activate Account")
|
||||||
|
|
Loading…
Reference in a new issue