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


Python User.password方法代码示例

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


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

示例1: setUpInitialData

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import password [as 别名]
    def setUpInitialData(self):
        # Create the default user
        user = User(email=self.username)
        user.password = self.password
        user.details = UserDetails(name="Test User", user=user)
        db.session.add(user)

        db.session.add(Grant(user=user, role=Roles.USER))

        # Create admin
        admin = User(email=self.admin_user)
        admin.password = self.admin_pass
        admin.details = UserDetails(name="Test Admin", user=admin)
        db.session.add(admin)

        db.session.add(Grant(user=admin, role=Roles.ADMIN))

        app = Application(owner=user, name="Test App")
        db.session.add(app)
        db.session.add(Grant(user=user, role=Roles.APP))

        client = Client(app=app, name="Mobile Client",
                        allowed_grant_types=[GrantTypes.PASSWORD, GrantTypes.REFRESH_TOKEN])
        db.session.add(client)

        db.session.commit()

        self.user_id = user.username
        self.admin_id = admin.id
        self.application_id = app.id
        self.client_id = client.id
开发者ID:cmabastar,项目名称:flask-rest-boilerplate,代码行数:33,代码来源:tests.py

示例2: create_admin_user

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import password [as 别名]
def create_admin_user(username, password):
    """Creates the administrator user.
    Returns the created admin user.

    :param username: The username of the user.

    :param password: The password of the user.
    """

    user = User.query.filter_by(username=username).first()
    if user:
        return user
    user = User()

    role = Role.query.filter_by(permissions=Permission.ADMINISTER).first()
    user.role = role
    user.username = username
    user.password = password

    user.save()
    return user
开发者ID:XiongZhijun,项目名称:simple-flask,代码行数:23,代码来源:populate.py

示例3: new_admin

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import password [as 别名]
def new_admin(email):
    """Create an administrator account"""

    # Check if the user already exists
    user = User.query.filter(User.email == email).first()
    if not user:
        user = User(email=email)
        user.password = request_password()
        db.session.add(user)
    else:
        sys.stdout.write("User '%s' already exists " % email)

    if not Grant.check_grant(user, Roles.ADMIN):
        if query_yes_no(", are you sure you want to grant admin rights?" % email, default="no"):
            db.session.add(Grant(user=user, role=Roles.ADMIN))
            db.session.commit()
            print("User with email '%s' is now an administrator" % email)
        else:
            return "Command cancelled"

    print("and is an administrator")
开发者ID:hairychris,项目名称:flask-rest-boilerplate,代码行数:23,代码来源:manage.py


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