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


Python User.passwd方法代码示例

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



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

示例1: api_register_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import passwd [as 别名]
async def api_register_user(*, email, name, passwd):
    '''
    这个函数其实是用来注册用户的。
    '''
    if not name or not name.strip():
        raise APIValueError('name')
    if not email or not _RE_EMAIL.match(email):
        raise APIValueError('email')
    if not passwd or not _RE_SHA1.match(passwd):
        raise APIValueError('passwd')
    uid = next_id()
    sha1_passwd = '%s:%s' % (uid, passwd)
    user = User(
        id=uid,
        name=name.strip(),
        email=email,
        passwd=hashlib.sha1(sha1_passwd.encode('utf-8')).hexdigest(),
        image='http://www.gravatar.com/avatar/%s?d=mm&s=120' % hashlib.md5(email.encode('utf-8')).hexdigest()
    )

    await user.save()
    # make session cookie:
    r = web.Response()
    # 登陆的时候要创建cookie信息
    r.set_cookie(COOKIE_NAME, user2cookie(user, 86400), max_age=86400, httponly=True)
    user.passwd = '******'
    r.content_type = 'application/json'
    r.body = json.dumps(user, ensure_ascii=False).encode('utf-8')
    return r
开发者ID:lishuhuakai,项目名称:CS,代码行数:31,代码来源:handlers.py


示例2: api_register_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import passwd [as 别名]
def api_register_user(*,email,name,passwd):
	logging.info('comming into register post users')
	if not name or not name.strip():
		raise APIValueError('name')
	if not name or not _RE_EMAIL.match(email):
		raise APIValueError('email')
	if not passwd or not _RE_SHA1.match(passwd):
		raise APIValueError('passwd')
	users = yield from User.findAll('email=?',[email])

	if len(users) > 0 :
		raise APIError('register:failed','email','Email is already in use.')
	uid = next_id()
	sha1_passwd = '%s:%s' %(uid,passwd)
	user = User(id=uid,name=name.strip(),email=email,passwd=hashlib.sha1(
		sha1_passwd.encode('utf-8')).hexdigest(),image='http://www.gravatar.com/avatar/%s?d=mm&s=120' % hashlib.md5(email.encode('utf-8')).hexdigest())
	yield from user.save()

	#make session cookie from here:
	r = web.Response()
	r.set_cookie(COOKIE_NAME,user2cookie(user,86400),max_age=86400,httponly=True)

	user.passwd = '******'
	r.content_type = 'application/json'
	r.body = json.dumps(user,ensure_ascii=False).encode('utf-8')

	return r 
开发者ID:wentixiaogege,项目名称:python3,代码行数:29,代码来源:handlers.py


示例3: manage_users

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import passwd [as 别名]
def manage_users(*, page='1'):
	return {
		'__template__':'manage_users.html',
		'page_index':get_page_index(page)
	}



	user = User(id = uid, name = name.strip(), email = email, passwd = hashlib.sha1(sha1_passwd.encode('utf-8')).hexdigest(), image = 'http://www.gravatar.com/avatar/%s?d=mm&s=120' % hashlib.md5(email.encode('utf-8')).hexdigest(), admin = admin)
	yield from user.save()
	logging.info('save user ok')

	r = web.Response()

	r.set_cookie(__COOKIE_NAME,user2cookie(user, 86400))

	user.passwd = '******'
	r.content_type = 'application/json'

	r.body = json.dumps(user, ensure_ascii =False).encode('utf-8')

	return r
开发者ID:yxw163,项目名称:awesome-python3-webapp,代码行数:24,代码来源:handler.py



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