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


Python User.password方法代码示例

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


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

示例1: route_register_api

# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import password [as 别名]
def route_register_api():
    if g.user:
        raise APIError("Already logged in!")

    params = {k:v for k, v in request.values.items() if k in ["username", "password", "email"]}

    if not all(params.values()):
        raise APIError("Missing required paramaters!")

    try:
        User.get((User.username == params["username"]) | (User.email == params["email"]))
        raise APIError("User with that username/email already exists!")
    except User.DoesNotExist: pass

    u = User(username=params["username"], email=params["email"])
    u.password = User.hash_password(params["password"])

    session["id"] = u.save()
    return APIResponse()
开发者ID:b1naryth1ef,项目名称:juicebox,代码行数:21,代码来源:app.py

示例2: updateUser

# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import password [as 别名]
def updateUser(cookie, uid, handle, name, pwd, admin, email):
    session = Session()
    u = usermanagment.getUser(cookie)
    if not u.admin and uid != u.id:
        raise Exception("Invalid access %s %s" % (uid, u.id))
    if uid == -1:
        cu = User(handle)
        session.add(cu)
    else:
        q = session.query(User).filter_by(id=uid)
        if q.count() == 0:
            raise Exception("User not found")
        cu = q.one()
    cu.name = name
    cu.email = email
    if pwd:
        cu.password = pwd
    if u.admin:
        cu.admin = admin
    session.commit()
    return cu.id
开发者ID:antialize,项目名称:djudge,代码行数:23,代码来源:rpc.py

示例3: route_register

# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import password [as 别名]
def route_register():
    if g.user:
        return redirect("/", code=302)

    if request.method == "GET":
        return render_template("register.html")

    params = {k:v for k, v in request.values.items() if k in ["username", "password", "email"]}

    if not all(params.values()):
        return redirect("/", code=302)

    try:
        User.get((User.username == params["username"]) | (User.email == params["email"]))
        return redirect("/", code=302)
    except User.DoesNotExist: pass

    u = User(username=params["username"], email=params["email"])
    u.password = User.hash_password(params["password"])

    session["id"] = u.save()
    g.user = u
    return redirect("/", code=302)
开发者ID:b1naryth1ef,项目名称:juicebox,代码行数:25,代码来源:app.py


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