本文整理汇总了Python中model.user.User.update_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.update_user方法的具体用法?Python User.update_user怎么用?Python User.update_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.update_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authenticate
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import update_user [as 别名]
def authenticate(self, request):
email = request.user_email
validate_email(email)
team_key = request.team_key
user = User.find_user_by_email(email, team_key)
if team_key:
team_secret = request.team_secret
validate_team_secret(team_secret)
display_name = request.display_name
image_url = request.user_image_url
if not user:
user = User.insert_user(email=email, username=display_name, account_type=team_key, image_url=image_url)
community = Community.getCommunityFromTeamKey(team_key)
UserRole.insert(user, community)
elif (display_name != user.display_name) or (image_url != user.image_url):
User.update_user(user=user, email=email, username=display_name, account_type=team_key, image_url=image_url)
if not Community.authenticate(team_key, md5(team_secret)):
raise endpoints.UnauthorizedException("Authentication failed. Team key and secret are not matched.")
elif user.auth_source == AuthSourceType.ANNO:
password = request.password
validate_password(password)
if not user:
raise endpoints.NotFoundException("Authentication failed. User account " + email + " doesn't exist.")
if not User.authenticate(email, md5(password)):
raise endpoints.UnauthorizedException("Authentication failed. Email and password are not matched.")
else:
raise endpoints.ForbiddenException("Account for '%s' is Google or Facebook OAuth account." % email)
return UserMessage(id=user.key.id(), display_name=user.display_name)
示例2: auth_user
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import update_user [as 别名]
def auth_user(headers):
current_user = get_endpoints_current_user(raise_unauthorized=False)
user = None
if current_user is None:
credential_pair = get_credential(headers)
signinMethod = SignInMethod.ANNO
team_key = None
team_secret = None
display_name = None
image_url = None
if len(credential_pair) == 2:
email, password = credential_pair
elif len(credential_pair) == 5:
signinMethod, email, password, team_key, team_secret = credential_pair
else:
signinMethod, email, password, team_key, team_secret, display_name, image_url = credential_pair
validate_email(email)
user = User.find_user_by_email(email, team_key)
if signinMethod == SignInMethod.ANNO:
User.authenticate(email, md5(password))
elif signinMethod == SignInMethod.PLUGIN:
if not Community.authenticate(team_key, team_secret):
raise endpoints.UnauthorizedException("Incorrect team key or secret")
display_name = unicode(display_name, "utf-8", "ignore")
if not user:
user = User.insert_user(email=email, username=display_name, account_type=team_key, image_url=image_url)
community = Community.getCommunityFromTeamKey(team_key)
UserRole.insert(user, community)
elif (display_name and display_name != user.display_name) or (image_url and image_url != user.image_url):
User.update_user(user=user, email=email, username=display_name, account_type=team_key, image_url=image_url)
else:
user = User.find_user_by_email(current_user.email())
if user is None:
raise endpoints.UnauthorizedException("Oops, something went wrong. Please try later.")
return user
示例3: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import update_user [as 别名]
def post(self):
self.set_header("Content-Type", "application/json")
try:
name = self.get_argument("name")
email = self.get_argument("email")
captcha = self.get_argument("captcha", "")
except:
self.write(json.dumps("用户名、邮箱、验证码均为必填项!"))
return
if captcha:
if self.get_secure_cookie("captcha") != captcha:
self.write(json.dumps("验证码填写错误!"))
return
else:
user_name_cookie = self.get_secure_cookie('username')
user_pw_cookie = self.get_secure_cookie('userpw')
if not User.check_user_password(user_name_cookie, user_pw_cookie):
self.write(json.dumps("重置密码失败!"))
return
if name and email and User.check_name_email(name, email):
pw = random_string(16)
User.update_user(name, email, pw)
sub = {
"%website%": [getAttr("SITE_TITLE").encode('utf-8')],
"%url%": [getAttr("BASE_URL")],
"%name%": [name],
"%password%": [pw]
}
#sendTemplateEmail(u"密码重置通知 - " + getAttr('SITE_TITLE'), sub, str(email))
sendEmail(u"密码重置通知 - " + getAttr('SITE_TITLE'), u"您的新密码是:" + pw + u"<br /><br />请及时登录并修改密码!", str(email))
self.write(json.dumps("OK"))
return
else:
self.write(json.dumps("重置密码失败!"))
return