def login_oauth2_user(valid, oauth):
    """Log in a user after having been verified."""
    if valid:
        oauth.user.login_via_oauth2 = True
        _request_ctx_stack.top.user = oauth.user
        identity_changed.send(current_app._get_current_object(),
                              identity=Identity(oauth.user.id))
    return valid, oauth
Log in a user after having been verified.