本文整理汇总了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
示例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
示例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")