Beispiel #1
0
 def create_admin_user(session, *args):
     attributes = args[0]
     user = User()
     user.update(attributes)
     user.set_role(session.query(UserRole).filter(UserRole.label == attributes["role"]).one())
     session.add(user)
     return user
Beispiel #2
0
 def create_user(session, *args):
     attributes = args[0]
     user = User()
     user.set_role(session.query(UserRole).filter(
         UserRole.label == UserRole.get_clearance(0)).one())
     user.update(attributes)
     session.add(user)
     return user
Beispiel #3
0
 def create_privileged_user(session, *args):
     attributes = args[0]
     payload = args[1]
     if User.is_admin(attributes):
         user = User()
         user.set_role(session.query(UserRole).filter(UserRole.label == attributes["role"]).one())
         user.update(attributes)
         session.add(user)
         return user
     else:
         raise AuthError