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:
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