예제 #1
0
파일: auth.py 프로젝트: mariajbp/LI4
    def post(self):
        args = RegisterAPI.parser_post.parse_args()

        id_user = args['id_user']
        name = args['name']
        password = args['password']
        email = args['email']

        if not (id_user and name and password and email):
            return error_message("Insuficient arguments"), 400

        ################## Input Validation ##################
        from common.utils import params_validation, VALID_ID_USER_REGEX, VALID_NAME_REGEX, VALID_PASSWORD_REGEX, VALID_EMAIL_REGEX

        params = [id_user, name, password, email]
        rgxs = [
            VALID_ID_USER_REGEX, VALID_NAME_REGEX, VALID_PASSWORD_REGEX,
            VALID_EMAIL_REGEX
        ]

        try:
            params_validation(rgxs, params)
        except ErrorCodeException as ec:
            return error_code(ec), 400
        ######################################################

        try:
            User.add_user(
                User(id_user, email, password, name, Permissions.USER))
            return success(), 200
        except ErrorCodeException as ec:
            return error_code(ec), 400
예제 #2
0
파일: user.py 프로젝트: mariajbp/LI4
    def post(self):
        body = request.json
        if not body:
            return {"error": "No json body found on request"}

        id_user = body['id_user']
        email = body['email']
        password = body['password']
        name = body['name']

        ################## Input Validation ##################
        from common.utils import params_validation, VALID_ID_USER_REGEX, VALID_NAME_REGEX, VALID_PASSWORD_REGEX, VALID_EMAIL_REGEX

        params = [id_user, name, password, email]
        rgxs = [
            VALID_ID_USER_REGEX, VALID_NAME_REGEX, VALID_PASSWORD_REGEX,
            VALID_EMAIL_REGEX
        ]

        try:
            params_validation(rgxs, params)
        except ErrorCodeException as ec:
            return error_code(ec), 400
        ######################################################

        try:
            User.add_user(
                User(body['id_user'], body['email'], body['password'],
                     body['name'], int(body['permissions'])))
            return success()
        except ErrorCodeException as ec:
            return error_code(ec)
예제 #3
0
파일: app.py 프로젝트: mariajbp/LI4
def populate():
    from binascii import unhexlify
    # Insert some users
    try:
        User.add_user(User("a12345","*****@*****.**","epah_mas_que_chatice","António Barosa",permissions=5))
    except:
        pass
    try:
        User.add_user(User("a11111","*****@*****.**","epah_mas_que_chatice","Adelino Costa"))
    except:
        pass
    try:
        User.add_user(User("a22222","*****@*****.**","epah_mas_que_chatice","Rosa Matilde"))
    except:
        pass
    try:
        User.add_user(User("a33333","*****@*****.**","epah_mas_que_chatice","Fernando Magalhães"))
    except:
        pass 
        
    # Insert some ticket types
    try:
        TicketType.add_type(TicketType(1,1.8,"simple"))
    except:
        pass
    try:
        TicketType.add_type(TicketType(2,2.5,"complete"))
    except:
        pass

    
    from model.meal import MealType , Location , Meal
    try:
        MealType.add_meal_type(MealType("lunch"))
    except:
        pass
    try:
        MealType.add_meal_type(MealType("dinner"))
    except:
        pass
    try:
        MealType.add_meal_type(MealType("lunch_veg"))
    except:
        pass
    try:
        MealType.add_meal_type(MealType("dinner_veg"))
    except:
        pass

    try:
        Location.add_location(Location("azurem"))
    except:
        pass
    try:
        Location.add_location(Location("gualtar"))
    except:
        pass

    from datetime import date
    try:
        Meal.add_meal(Meal(date.fromisoformat('2019-12-04'),1,1,soup="Sopa de Frango",main_dish="Frango"))
    except:
        pass