本文整理汇总了Python中gluon.sqlhtml.SQLFORM.vars[passfield]方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.vars[passfield]方法的具体用法?Python SQLFORM.vars[passfield]怎么用?Python SQLFORM.vars[passfield]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.sqlhtml.SQLFORM
的用法示例。
在下文中一共展示了SQLFORM.vars[passfield]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import vars[passfield] [as 别名]
def login(
self,
next=DEFAULT,
onvalidation=DEFAULT,
onaccept=DEFAULT,
log=DEFAULT,
):
"""
Overrides Web2Py's login() to use custom flash styles & utcnow
returns a login form
.. method:: Auth.login([next=DEFAULT [, onvalidation=DEFAULT
[, onaccept=DEFAULT [, log=DEFAULT]]]])
"""
table_user = self.settings.table_user
if "username" in table_user.fields:
username = "username"
else:
username = "email"
old_requires = table_user[username].requires
table_user[username].requires = IS_NOT_EMPTY()
request = self.environment.request
response = self.environment.response
session = self.environment.session
passfield = self.settings.password_field
if next == DEFAULT:
next = request.vars._next or self.settings.login_next
if onvalidation == DEFAULT:
onvalidation = self.settings.login_onvalidation
if onaccept == DEFAULT:
onaccept = self.settings.login_onaccept
if log == DEFAULT:
log = self.messages.login_log
user = None # default
# do we use our own login form, or from a central source?
if self.settings.login_form == self:
form = SQLFORM(
table_user,
fields=[username, passfield],
hidden=dict(_next=request.vars._next),
showid=self.settings.showid,
submit_button=self.messages.submit_button,
delete_label=self.messages.delete_label,
)
accepted_form = False
if form.accepts(request.vars, session,
formname="login", dbio=False,
onvalidation=onvalidation):
accepted_form = True
# check for username in db
users = self.db(table_user[username] == form.vars[username]).select()
if users:
# user in db, check if registration pending or disabled
temp_user = users[0]
if temp_user.registration_key == "pending":
response.warning = self.messages.registration_pending
return form
elif temp_user.registration_key == "disabled":
response.error = self.messages.login_disabled
return form
elif temp_user.registration_key:
response.warning = \
self.messages.registration_verifying
return form
# try alternate logins 1st as these have the current version of the password
for login_method in self.settings.login_methods:
if login_method != self and \
login_method(request.vars[username],
request.vars[passfield]):
if not self in self.settings.login_methods:
# do not store password in db
form.vars[passfield] = None
user = self.get_or_create_user(form.vars)
break
if not user:
# alternates have failed, maybe because service inaccessible
if self.settings.login_methods[0] == self:
# try logging in locally using cached credentials
if temp_user[passfield] == form.vars.get(passfield, ""):
# success
user = temp_user
else:
# user not in db
if not self.settings.alternate_requires_registration:
# we're allowed to auto-register users from external systems
for login_method in self.settings.login_methods:
if login_method != self and \
login_method(request.vars[username],
request.vars[passfield]):
if not self in self.settings.login_methods:
# do not store password in db
form.vars[passfield] = None
user = self.get_or_create_user(form.vars)
break
if not user:
# invalid login
#.........这里部分代码省略.........