@classmethod
def get_user(cls, handler):
    """Called by handlers.get_current_user for identifying the current user.

        See tornado.web.RequestHandler.get_current_user for details.
        """
    if getattr(handler, '_user_id', None):
        return handler._user_id
    user_id = cls.get_user_token(handler)
    if user_id is None:
        user_id = handler.get_secure_cookie(handler.cookie_name)
    else:
        cls.set_login_cookie(handler, user_id)
        handler._token_authenticated = True
    if user_id is None:
        handler.clear_login_cookie()
        if not handler.login_available:
            user_id = 'anonymous'
    handler._user_id = user_id
    return user_id
