#NEWLINE# @ gen . coroutine #NEWLINE# def get_authenticated_user( self , handler , data ) : #NEWLINE# #INDENT# 'This is the outer API for authenticating a user.\n        \n        This calls `authenticate`, which should be overridden in subclasses,\n        normalizes the username if any normalization should be done,\n        and then validates the name in the whitelist.\n        \n        Subclasses should not need to override this method.\n        The various stages can be overridden separately:\n        \n        - authenticate turns formdata into a username\n        - normalize_username normalizes the username\n        - check_whitelist checks against the user whitelist\n        ' #NEWLINE# username = ( yield self . authenticate ( handler , data ) ) #NEWLINE# if ( username is None ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# username = self . normalize_username ( username ) #NEWLINE# if ( not self . validate_username ( username ) ) : #NEWLINE# #INDENT# self . log . warning ( 'Disallowing invalid username %r.' , username ) #NEWLINE# return #NEWLINE# #UNINDENT# if self . check_whitelist ( username ) : #NEWLINE# #INDENT# return username #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . log . warning ( 'User %r not in whitelist.' , username ) #NEWLINE# return