Ejemplo n.º 1
0
 def get(self):
     auth_token = request.headers.get('x-auth-token')
     if not auth_token or auth_token is None:
         response = {'success': False, 'message': 'Please provide a token'}
         return response, 401
     response, code = AuthService.logout_student(auth_token=auth_token)
     return response, code
Ejemplo n.º 2
0
    def get(self):
        ''' Verify a token's validity '''
        auth_token = request.headers.get('x-auth-token')
        if not auth_token or auth_token is None:
            response = {'success': False, 'message': 'Please provide a token'}
            return response, 401

        response, code = AuthService.verify(auth_token=auth_token)
        return response, code
Ejemplo n.º 3
0
    def post(self):
        data = request.json
        payload = lecturer_auth_api.payload or data
        schema = LecturerLoginSchema()

        try:
            new_payload = schema.load(payload)._asdict()
        except ValidationError as e:
            response = {'success': False, 'error': e.messages}
            return response, 400

        response, code = AuthService.login_lecturer(data=new_payload)
        return response, code
Ejemplo n.º 4
0
    def post(self):
        ''' Authenticate a student '''
        data = request.json
        payload = student_auth_api.payload or data
        schema = StudentLoginSchema()

        try:
            new_payload = schema.load(payload)._asdict()
        except ValidationError as e:
            response = {'success': False, 'error': e.messages}
            return response, 400

        response, code = AuthService.login_student(data=new_payload)
        return response, code