def require_valid_sender(handler):
 def test_user(self, **kwargs):
  'Checks if the user is logged in and is authorized sender.'
  if (not self.user_id):
   self.redirect(current_user_services.create_login_url(self.request.uri))
   return
  if (self.username not in config_domain.WHITELISTED_EMAIL_SENDERS.value):
   raise self.UnauthorizedUserException('%s is not an authorized user of this application', self.user_id)
  return handler(self, **kwargs)
 return test_user

def require_valid_sender ( handler ) : def test_user ( self , ** kwargs ) : if ( not self . user_id ) : self . redirect ( current_user_services . create_login_url ( self . request . uri ) ) return if ( self . username not in config_domain . WHITELISTED_EMAIL_SENDERS . value ) : raise self . UnauthorizedUserException ( '%s is not an authorized user of this application' , self . user_id ) return handler ( self , ** kwargs ) return test_user
decorator that checks if the current user is a authorized sender .