Exemple #1
0
class TokenResource(Resource):
    method_decorators = [protected(AuthType.Simple, False)]

    def post(self):
        """Get bearer token via simple auth."""
        payload = {'user': g.user, 'token': create_access_token(g.user.id)}
        return IkiruJsonResponse(payload, 'Access token created successfully.')
Exemple #2
0
class ReturnsResource(Resource):
    method_decorators = [protected(AuthType.JWT, self_only=True)]

    post_parser = reqparse.RequestParser()
    post_parser.add_argument('rental_uuid', dest='rental_uuid', required=True)

    def post(self):
        # post_parser remains editable - service layer is responsible
        # for copying the parser before doing any live edits
        return services.rental.return_rental(self.post_parser)
Exemple #3
0
class EvalResource(Resource):
    method_decorators = [protected(AuthType.JWT, False)]

    def post(self):
        """ Check token validity."""
        jwt = get_raw_jwt()
        return IkiruJsonResponse({
            'user':
            g.user,
            'date_expires':
            datetime.utcfromtimestamp(jwt['exp'])
        })
Exemple #4
0
class UserRentalsResource(Resource):
    method_decorators = [protected(AuthType.JWT, self_only=True)]

    def get(self, user_uuid):
        return services.user.get_user_rentals(user_uuid)
Exemple #5
0
class GenresResource(Resource):
    method_decorators = [protected(AuthType.JWT)]

    def get(self):
        return services.genre.get_genres()
Exemple #6
0
class GenreMoviesResource(Resource):
    method_decorators = [protected(AuthType.JWT)]

    def get(self, genre_uuid):
        return services.genre.get_genre_movies(genre_uuid)
Exemple #7
0
class MovieResource(Resource):
    method_decorators = [protected(AuthType.JWT)]

    def get(self, movie_uuid):
        return services.movie.get_movie_by_uuid(movie_uuid)
Exemple #8
0
class ReturnResource(Resource):
    method_decorators = [protected(AuthType.JWT, self_only=True)]

    def get(self, rental_uuid):
        return services.rental.get_cost(rental_uuid)