def decorated(*args, **kwargs): login = external_auth(request) if login: User.create_if_not_exists(login) session['login'] = login return f(*args, **kwargs) token = request.args.get('token', None) if token and Token.query.filter_by(value=token).first(): return f(*args, **kwargs) return 'Not authenticated', 401
def decorated(*args, **kwargs): try: login = external_auth(request) except: login = None if login: if not dao_user.does_exist(login): u = domain_usr.UserBuilder.from_login(login) dao_user.insert(u) session['login'] = login return f(*args, **kwargs) auth = request.authorization if auth: token_owner = dao_token.Token.meet(auth.username, auth.password) if token_owner: session['login'] = token_owner return f(*args, **kwargs) return 'Not authenticated', 401
def decorated(*args, **kwargs): try: login = external_auth(request) except: login = None if login: if not dao_user.does_exist(login): u = domain_usr.UserBuilder.from_login(login) dao_user.insert(u) session["login"] = login return f(*args, **kwargs) auth = request.authorization if auth: token_owner = dao_token.Token.meet(auth.username, auth.password) if token_owner: session["login"] = token_owner return f(*args, **kwargs) return "Not authenticated", 401