def requires_auth(f):
 @wraps(f)
 def decorated(*args, **kwargs):
  message = 'Authentication credentials not found'
  success = False
  try:
   auth_jwt()
   success = True
  except JWTError as e:
   if ((e.headers is not None) and ('WWW-Authenticate' not in e.headers)):
    raise NotAuthorizedError(message=((e.error + ': ') + e.description))
  if (not success):
   results = auth_basic()
   if (not results[0]):
    if results[1]:
     raise NotAuthorizedError(message=results[1])
   else:
    success = True
  if (not success):
   if login.current_user.is_authenticated:
    g.user = UserModel.query.get(login.current_user.id)
    success = True
  else:
   g.user.update_lat()
  if success:
   return f(*args, **kwargs)
  else:
   raise NotAuthorizedError(message=message)
 return decorated

def requires_auth ( f ) : @ wraps ( f ) def decorated ( * args , ** kwargs ) : message = 'Authentication credentials not found' success = False try : auth_jwt ( ) success = True except JWTError as e : if ( ( e . headers is not None ) and ( 'WWW-Authenticate' not in e . headers ) ) : raise NotAuthorizedError ( message = ( ( e . error + ': ' ) + e . description ) ) if ( not success ) : results = auth_basic ( ) if ( not results [ 0 ] ) : if results [ 1 ] : raise NotAuthorizedError ( message = results [ 1 ] ) else : success = True if ( not success ) : if login . current_user . is_authenticated : g . user = UserModel . query . get ( login . current_user . id ) success = True else : g . user . update_lat ( ) if success : return f ( * args , ** kwargs ) else : raise NotAuthorizedError ( message = message ) return decorated
decorator for :class:tvdbclient methods that require authentication .