当前位置: 首页>>代码示例>>Python>>正文


Python User.checkToken方法代码示例

本文整理汇总了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)
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:37,代码来源:mygroups.py

示例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'}))
开发者ID:elkana-d,项目名称:geTremp-master,代码行数:33,代码来源:main.py

示例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
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:29,代码来源:newlinks.py

示例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)
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:31,代码来源:details.py

示例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)
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:33,代码来源:sign_up.py

示例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}))
开发者ID:jce-il,项目名称:gae-login-example,代码行数:28,代码来源:add_member.py

示例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)
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:37,代码来源:contactspage.py

示例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)
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:61,代码来源:mygroupschat.py

示例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)
开发者ID:jce-il,项目名称:gae-login-example,代码行数:16,代码来源:main.py

示例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}))
开发者ID:jce-il,项目名称:gae-login-example,代码行数:19,代码来源:create_group.py

示例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 
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:20,代码来源:mysavedlinks.py

示例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
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:20,代码来源:add_memebr.py

示例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
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:23,代码来源:delete_group.py

示例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
开发者ID:babaniassaf,项目名称:ShareLink,代码行数:24,代码来源:create_group.py


注:本文中的models.user.User.checkToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。