def authorize_user(self, request): x_auth_key = request.headers['X-AUTH-KEY'] serializer = URLSafeSerializer(secret_key=settings.TOKEN_SECRET_KEY) try: user = User() user.id = serializer.loads(x_auth_key) self.is_authorized_user = user.get_user() self.user_id = user.id return self.is_authorized_user except BadSignature: return False except BadPayload: return False except: print sys.exc_info()[0] return False
def __init__(self, auth_header): self.auth_header = auth_header s = URLSafeSerializer(secret_key=settings.TOKEN_SECRET_KEY) try: self.auth_key = s.loads(self.auth_header['X-AUTH-KEY']) # self.user_key = self.auth_header['X-AUTH-USER'] user = User() user.id = self.auth_key user.get_user() self.is_authorized_user = user.id == self.auth_key # users auth key is valid except BadSignature: self.is_authorized_user = False except BadPayload: self.is_authorized_user = False except: print sys.exc_info()[0] self.is_authorized_user = False
def update_user(self, user_result_json, user_id): user = User() user.id = user_id user.set_user_properties(user_result_json) user.update_user()
def get_group_user(user_id): user = User() user.id = user_id user.get_user() return user
def get_user_by_id(user_id): user = User() user.id = user_id user.get_user() return user