Ejemplo n.º 1
0
    def execute(self, reset_password_token, password):
        user = User.get(User.reset_password_token == reset_password_token)

        hashed_password = AuthenticationService.hash_password(password)
        user.reset_password(password=hashed_password)

        user.save()
Ejemplo n.º 2
0
    def execute(self, email):
        try:
            user = User.get(User.email == email)
        except DoesNotExist:
            return None

        user.generate_reset_password_token()
        user.save()

        self.__send_reset_password_email.execute(user=user)
Ejemplo n.º 3
0
def profile():
    token = request.headers.get('Authorization')

    if not token:
        return jsonify(errors='Not authorized'), 401

    try:
        _, token = token.split('Bearer ')
    except ValueError:
        return jsonify(errors='Not authorized'), 401

    token_data = Token.validate_token(token=token)

    user = User.get(id=token_data['id'])

    return jsonify(UserSerializer().serialize(user)), 200
Ejemplo n.º 4
0
    def execute(self, activation_token):
        user = User.get(User.activation_token == activation_token)

        user.activate()

        user.save()