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


Python User.authenticate方法代码示例

本文整理汇总了Python中users.User.authenticate方法的典型用法代码示例。如果您正苦于以下问题:Python User.authenticate方法的具体用法?Python User.authenticate怎么用?Python User.authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在users.User的用法示例。


在下文中一共展示了User.authenticate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import authenticate [as 别名]
	def post(self):
		user = User.authenticate(self.request.get('nickname'), self.request.get('password'))
		if user and not user.suspended:
			self.session.start(user)
			redirect = self.request.get('redirect')
			self.redirect(redirect)
		else:
			self.session.start( None )
			self.session['flash_msg'] = '<p>Incorrect nickname/password combination. Sorry!</p>'
			self.redirect(self.request.url)
开发者ID:jpstacey,项目名称:suas,代码行数:12,代码来源:auth_handlers.py

示例2: post

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import authenticate [as 别名]
 def post(self):
     nickname = self.request.get('nickname')
     email = self.request.get('email')
     password = self.request.get('password')
     password2 = self.request.get('password2')
     if password2 != password:
         self.session.start(None)
         self.session[ 'flash_msg' ] = '<p>Password fields did not match.</p>'
         self.redirect('/signup')
         return
     user = User.get_or_insert(nickname=nickname,
                 email=email,
                 pwd=salt_n_hash(password),
                 key_name=nickname)
     self.session.start(None)
     if not User.authenticate(nickname, password):
         self.session[ 'flash_msg' ] = '<p>Sorry, the nickname you chose is already taken.</p>'
         self.redirect(self.request.url)
         return
     id = signup_id(nickname)
     signup = UserSignup(user=user, key_name=id)
     signup.put()
     confirm_url = self.request.relative_url('confirmsignup?id='+id)
     logging.info("user:" + nickname + " password:" + password + " confirm_url:" +confirm_url)
     from google.appengine.api import mail
     #sender = 'Registrar <[email protected]>'
     sender = '[email protected]'
     subject = 'Confirm your registration'
     body = \
         'Hello %s,\n\n' % nickname + \
         'To confirm your registration, please visit the link below:\n\n' + \
         '<%s>\n' % confirm_url
     mail.send_mail( sender, email, subject, body )
     self.session['flash_msg'] = \
         '<p>Thank you for signing up, %s! A confirmation ' % nickname + \
         'message is on its way to your email inbox. It will contain a link ' + \
         'which you will need to visit in order to complete your registration.</p>' + \
         '<p>See you soon!</p>'
     self.redirect('/')
开发者ID:lite,项目名称:deone,代码行数:41,代码来源:auth_handlers.py


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