Ejemplo n.º 1
0
 def password_reset(self, request):
     serializer = self.get_serializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     user = user_services.get_user_by_email(serializer.data['email'])
     if user:
         services.send_password_reset_mail(user)
     return response.Ok({'message': 'Further instructions will be sent to the email if it exists'})
Ejemplo n.º 2
0
def create_user(
    user: _schemas.UserCreate, db: _orm.Session = _fastapi.Depends(_services.get_db)
):
    db_user = _services.get_user_by_email(db=db, email=user.email)
    if db_user:
        raise _fastapi.HTTPException(
            status_code=400, detail="woops the email is in use"
        )
    return _services.create_user(db=db, user=user)
Ejemplo n.º 3
0
 def validate_email(self, value):
     user = user_services.get_user_by_email(email=value)
     if user:
         raise serializers.ValidationError("Email is already taken.")
     return UserManager.normalize_email(value)
Ejemplo n.º 4
0
 def validate_email(self, email):
     user = services.get_user_by_email(email.data)
     if user is not None:
         raise ValidationError('Please use a different email address.')