# Как пропустить окно «Создать новую учётную запись» при использовании кастомного ManagedAuthenticator + стратегии OmniAuth?

**URL:** <https://meta.discourse.org/t/how-to-skip-create-new-account-window-when-using-custom-managedauthenticator-omniauth-strategy/155579>\
**Category:** Development\
**Created:** [22.Июнь.2020 15:18:41 UTC](https://meta.discourse.org/t/how-to-skip-create-new-account-window-when-using-custom-managedauthenticator-omniauth-strategy/155579 "2020-06-22T15:18:41Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Hooksmith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hooksmith/32/142826_2.png) [@Hooksmith](https://meta.discourse.org/u/Hooksmith)\
**Post date:** [22.Июнь.2020 15:18:41 UTC](https://meta.discourse.org/t/how-to-skip-create-new-account-window-when-using-custom-managedauthenticator-omniauth-strategy/155579/1 "2020-06-22T15:18:41Z")

</div>

Я реализовал кастомную стратегию OmniAuth + аутентификатор, который расширяет Discourse::Auth::ManagedAuthenticator.

Однако при тестировании в моей среде разработки я в конечном итоге попадаю на этот экран, вместо того чтобы сразу войти в систему:

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/d/cdbdb67693fbb8e544688bf5008dabfc73fbf137.png)

Информация заполняется корректно из хэша аутентификации, но я не хочу, чтобы пользователи могли изменять здесь своё имя пользователя или имя. Как изменить мою реализацию или настройки форума, чтобы этот экран пропускался, и учётная запись пользователя сразу создавалась (если её не существует) и выполнялся вход?

**Аутентификатор:**

```ruby
class MyAuthenticator < ::Auth::ManagedAuthenticator

    def name
        'my_authenticator'
    end

    def enabled?
        true
    end

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

```

**Стратегия:**

```ruby
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:**

```ruby
before_auth do
    ...

    auth_provider authenticator: MyAuthenticator.new()

    ...
end

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-skip-create-new-account-window-when-using-custom-managedauthenticator-omniauth-strategy/155579)._
