本文整理汇总了Python中models.user.User.checkToken方法的典型用法代码示例。如果您正苦于以下问题:Python User.checkToken方法的具体用法?Python User.checkToken怎么用?Python User.checkToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.checkToken方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
template_params={}
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
html = template.render("web/templates/index.html", {})
self.response.write(html)
return
#newlinks
linkslist=Link.getAllLinksPerUser(user)
newurls = []
template_params = {}
if linkslist:
for link in linkslist:
url = link.url_link
des = link.description
fromlink=link.from_link
if fromlink is not None:
urlandlink =[url,des,fromlink]
newurls.append(urlandlink)
template_params['newurls'] = newurls
#newlinks
template_params['useremail'] = user.email
grouplist= Group.getAllGroups(user)
groups= []
if grouplist:
for group in grouplist:
group_name= group['group_name']
groupid=group['id']
one=[group_name,groupid]
groups.append(one)
template_params['groupss']= groups
html = template.render("web/templates/mygroups.html", template_params)
self.response.write(html)
示例2: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
oldpassword = self.request.get('oldpassword')
newpassword1 = self.request.get('newpassword1')
newpassword2 = self.request.get('newpassword2')
if not oldpassword or not newpassword1 or not newpassword2:
self.error(403)
self.response.write('Empty password submitted')
return
if newpassword1 != newpassword2:
self.error(403)
self.response.write('Passwords do not match')
return
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
else:
self.redirect('/')
if not user.checkPassword(oldpassword):
self.error(403)
self.response.write('Wrong oldpassword')
return
user.setPassword(newpassword1)
user.put()
self.response.write(json.dumps({'status':'OK'}))
示例3: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
template_params={}
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
html = template.render("web/templates/index.html", {})
self.response.write(html)
return
linkslist=Link.getAllLinksPerUser(user)
#sorted(linkslist, key=lambda link: link.time_of_enter_the_link') # sort by age
newurls = []
template_params = {}
if linkslist:
for link in linkslist:
url = link.url_link
des = link.description
fromlink=link.from_link
if fromlink is not None:
urlandlink =[url,des,fromlink]
newurls.append(urlandlink)
template_params['newurls'] = newurls
template_params['useremail'] = user.email
html = template.render("web/templates/newlinks.html", template_params)
self.response.write(html)
return
示例4: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
template_params = {}
# user = User.checkUser()
# if not user:
# template_params['loginUrl'] = User.loginUrl()
# else:
# template_params['logoutUrl'] = User.logoutUrl()
# template_params['user'] = user.email
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if user:
#newlinks
linkslist=Link.getAllLinksPerUser(user)
newurls = []
template_params = {}
if linkslist:
for link in linkslist:
url = link.url_link
des = link.description
fromlink=link.from_link
if fromlink is not None:
urlandlink =[url,des,fromlink]
newurls.append(urlandlink)
template_params['newurls'] = newurls
#newlinks
template_params['useremail'] = user.email
html = template.render("web/templates/details.html", template_params)
self.response.write(html)
示例5: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
template_params = {}
# email = self.request.get('email')
# password = self.request.get('password')
# if not password:
# self.error(403)
# self.response.write('Empty password submitted')
# return
# user = User.query(User.email == email).get()
# if user:
# self.error(402)
# self.response.write('Email taken')
# return
# user = User()
# user.email = email
# user.setPassword(password)
# user.put()
# self.response.set_cookie('our_token', str(user.key.id()))
# self.response.write(json.dumps({'status':'OK'}))
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if user:
template_params['useremail'] = user.email
html = template.render("web/templates/index.html", template_params)
self.response.write(html)
return
html = template.render("web/templates/sign_up.html", template_params)
self.response.write(html)
示例6: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
group = Group.get_by_id(int(self.request.get('group_id')))
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user or group.admin != user.key:
self.error(403)
self.response.write('access denied')
return
new_user_email = self.request.get('member_email')
logging.info("Email {}".format(new_user_email))
new_user = User.query(User.email == new_user_email).get()
if not new_user:
self.error(404)
self.response.write('User with email {} not found'.format(new_user_email))
return
group.members.append(new_user.key)
group.put()
members = group.getMembers()
time.sleep(0.5)
self.response.write(json.dumps({"status": "OK", "members": members}))
示例7: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
template_params={}
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
html = template.render("web/templates/index.html", {})
self.response.write(html)
return
#newlinks
linkslist=Link.getAllLinksPerUser(user)
newurls = []
template_params = {}
if linkslist:
for link in linkslist:
url = link.url_link
des = link.description
fromlink=link.from_link
if fromlink is not None:
urlandlink =[url,des,fromlink]
newurls.append(urlandlink)
template_params['newurls'] = newurls
#newlinks
template_params['useremail'] = user.email
contactlist= Contact.getAllContactsPerUser(user)
contacts= []
if contactlist:
for contact in contactlist:
contact_email= contact.contact_user_email
contact_nickname= contact.nick_name
email_and_nickname= [contact_email, contact_nickname]
contacts.append(email_and_nickname)
template_params['contacts']=contacts
html = template.render("web/templates/contactspage.html", template_params)
self.response.write(html)
示例8: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self, group_id):
template_params={}
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
html = template.render("web/templates/index.html", {})
self.response.write(html)
return
#newlinks
linkslist=Link.getAllLinksPerUser(user)
newurls = []
template_params = {}
if linkslist:
for link in linkslist:
url = link.url_link
des = link.description
fromlink=link.from_link
if fromlink is not None:
urlandlink =[url,des,fromlink]
newurls.append(urlandlink)
template_params['newurls'] = newurls
#newlinks
template_params['useremail'] = user.email
grouplist= Group.getAllGroups(user)
groups= []
if grouplist:
for group in grouplist:
group_name= group['group_name']
groupid=group['id']
one=[group_name,groupid]
groups.append(one)
template_params['groupss']= groups
group = Group.get_by_id(int(group_id))
if group is None:
return
if group.admin != user.key and user.key not in group.members:
template_params['no_access'] = True
html = template.render('web/templates/mygroups.html', template_params)
self.response.write(html)
return
else:
template_params['group_name'] = group.group_name
template_params['group_id'] = group_id
linksInGroup=group.getLinks()
links= []
for link in linksInGroup:
link_user_name= link['email']
link_description= link['description']
link_url_link= link['url_link']
link_date= link['time_of_enter_the_link']
one=[link_user_name,link_description,link_url_link,link_date]
links.append(one)
links.reverse()
template_params['links']= links
html = template.render('web/templates/mygroupschat.html', template_params)
self.response.write(html)
示例9: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
user = None
template_vars = {}
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
self.redirect('/')
template_vars['email'] = user.email
template_vars['groups_num'] = 'To be implemented'
html = template.render('web/templates/personal.html', template_vars)
self.response.write(html)
示例10: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
self.error(403)
self.response.write('No user - access denied')
return
group = Group()
group.title = self.request.get('title')
group.admin = user.key
group.put()
time.sleep(0.5)
groups = Group.getAllGroups(user)
self.response.write(json.dumps({"status": "OK", "groups": groups}))
示例11: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
description = self.request.get('description')
url_link = self.request.get('url_link')
from_link = self.request.get('from_link')
if from_link == 'None':
from_link=None
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user :
html = template.render("web/templates/index.html", {})
self.response.write(html)
return
#link=Link.getLink(user.key,url_link,description,None)
Link.remove(user.key,url_link,description,from_link)
self.response.set_cookie('our_token', str(user.key.id()))
self.response.write(json.dumps({'status':'OK'}))
return
示例12: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
member=self.request.get('member')
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
self.error(403)
self.response.write('No user')
self.response.write(html)
return
if (user.email==member):
return
mem=User.checkIfUesr(member)
if mem is None:
return
self.response.set_cookie('our_token', str(user.key.id()))
self.response.write(json.dumps({'status':'OK'}))
return
示例13: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
self.error(403)
self.response.write('No user')
self.response.write(html)
return
group_to_remove= Group.get_by_id(int(self.request.get('groupid')))
if group_to_remove is None:
return
if group_to_remove.admin == user.key:
group_to_remove.remove_group()
else:
group_to_remove.removeUserFromTheGroup(user)
time.sleep(0.5)
self.response.set_cookie('our_token', str(user.key.id()))
self.response.write(json.dumps({'status':'OK'}))
return
示例14: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import checkToken [as 别名]
def get(self):
template_params={}
group_name=self.request.get('group_name')
members= json.loads(self.request.get('members'))
user = None
if self.request.cookies.get('our_token'): #the cookie that should contain the access token!
user = User.checkToken(self.request.cookies.get('our_token'))
if not user:
self.error(403)
self.response.write('No user')
self.response.write(html)
return
group= Group()
group.group_name=group_name
group.admin= user.key
for newM in members:
usermem= User.checkIfUesr(newM)
group.members.append(usermem.key)
group.put()
self.response.set_cookie('our_token', str(user.key.id()))
self.response.write(json.dumps({'status':'OK'}))
return