def is_user_logged(): if 'X-Token' in request.headers: token = request.headers['X-Token'] elif 'token' in request.cookies: token = request.cookies.get('token') elif request.content_type == 'application/json': token = request.json.get('token') else: logging.debug("No token provided!") return None if not token: logging.debug("No authentication was supplied") abort(401, 'Please supply authentication') user = UserEntity.verify_auth_token(token) return user
def verify_token(token): user = UserEntity.verify_auth_token(token) return User.from_model(user)