How to skip "Create New Account" window when using custom ManagedAuthenticator + OmniAuth strategy?

I’ve implemented a custom OmniAuth strategy + an authenticator that extends Discourse’s Auth::ManagedAuthenticator.

However, when testing this in my development environment, I eventually end up on this screen, rather than immediately being logged in:

image

The information is filled out correctly from the auth hash, however, I do not want users to be able to change their username or name here. How do I change my implementation / forum settings so that this screen is skipped and the user account is immediately created (if not existing) and logged in?

Authenticator:

class MyAuthenticator < ::Auth::ManagedAuthenticator

    def name
        'my_authenticator'
    end

    def enabled?
        true
    end

    def register_middleware(omniauth)
        omniauth.provider name.to_sym, {}
    end
    
end

Strategy:

require 'omniauth'

...

class OmniAuth::Strategies::MyAuthenticator
    include OmniAuth::Strategy

    option :name, "my_authenticator"

    ...

    def callback_phase
        ...

        @user_id = ...
        @username = ...
        @avatar = ...
        @email = ...

        ...
    end
	
	...
	
    def auth_hash
        {
            provider: "my_authenticator",
            uid: @user_id,
            info: {
                name: @username,
                image: @avatar,
                email: @email
            },
            extra: {}
        }
    end

end

OmniAuth.config.add_camelization('my_authenticator', 'MyAuthenticator')

plugin.rb:

before_auth do
    ...

    auth_provider authenticator: MyAuthenticator.new()

    ...
end
1 Like

This is coming in a few weeks

4 Likes

So reading through the PR, it looks like this can be turned on just by toggling settings, and it wouldn’t require a code change to the custom authenticator once this releases, right?

Exactly. I believe @david plan is to merge a week or two after we release 2.5 on 2020-06-25T03:00:00Z

5 Likes

This is now merged

5 Likes