Example #1
0
    def validateAuthorization(*args, **kwargs):

        user = UserTransactions.findUserById(request.headers.get('facebookId'))
        if user is None:
            return_data = Responses.unauthorized('FacebookId not found')
            return return_data["data"], return_data["status"], {
                'message': return_data["message"]
            }

        token = request.headers.get('token')

        if token != user['token']:
            return_data = Responses.unauthorized('Invalid token')
            return return_data["data"], return_data["status"], {
                'message': return_data["message"]
            }

        current_date_seconds = time.mktime(
            datetime.datetime.utcnow().timetuple())
        exp_date_seconds = time.mktime(user['exp_date'].timetuple())
        if current_date_seconds > exp_date_seconds:
            return_data = Responses.unauthorized('Expirated token')
            return return_data["data"], return_data["status"], {
                'message': return_data["message"]
            }

        return function(*args, **kwargs)
Example #2
0
    def validateAuthorization(*args, **kwargs):

        user = request.headers.get('UserId')
        if user != "admin":
            return_data = Responses.unauthorized('UserId not found')
            return return_data["data"], return_data["status"], {
                'message': return_data["message"]
            }

        token = request.headers.get('Token')

        if token != "57.fcmXg$S@sx-bZ":
            return_data = Responses.unauthorized('Invalid token')
            return return_data["data"], return_data["status"], {
                'message': return_data["message"]
            }

        return function(*args, **kwargs)