Beispiel #1
0
async def change_user_password(
    old_password: str,
    current_password: str,
    user: User = Depends(get_current_active_user)) -> User:
    if not verify_password(old_password, user.password):
        return Http400("Incorrect password")
    user.password = current_password
    user.save()
    return user
Beispiel #2
0
 async def set_staff_user(id: int, active: bool) -> User:
     await User.filter(id=id).update(is_superuser=active)
     return await model.from_queryset_single(User.get(id=id))
Beispiel #3
0
 async def update(id: int, user: UserUpdateSchema):
     await User.filter(id=id).update(**user.dict(exclude_unset=True))
     return await model.from_queryset_single(User.get(id=id))
Beispiel #4
0
 async def reset_user_password(id: int, password: str) -> User:
     await User.filter(id=id).update(password=hash_password(password))
     return await model.from_queryset_single(User.get(id=id))
Beispiel #5
0
 async def get(id: int = None):
     if (id is not None):
         return await model.from_queryset_single(User.get(id=id))
     return await model.from_queryset(User.all())