OctoberCMS Como substituir o plug-in de usuários na função onRegister ()?

estou a usarOctoberCMS baseado no Laravel.

Estou tentando substituir oPlug-in de Usuários onRegister() função.

Uma resposta anterior me ajudou a estender o plugin.

Quero restringir nomes de usuário a alfanuméricos apenas comalpha_dash e limite para 50 caracteres.

A função original emAccount.php

public function onRegister()
{
...
    if ($this->loginAttribute() == UserSettings::LOGIN_USERNAME) {
        $rules['username'] = 'required|between:2,255';
    }

My Override

Documentos de Eventos do Usuáriohttps://github.com/rainlab/user-plugin#events

public function boot() {

    \RainLab\User\Models\User::extend(function($model) {

        $model->bindEvent('model.beforeUpdate', function() use ($model) {

            # User Register
            \Event::listen('rainlab.user.register', function($user, $data) {

                if ($this->loginAttribute() == UserSettings::LOGIN_USERNAME) {
                    $rules['username'] = 'required|alpha_dash|between:2,50';
                }

            });
        }); 
    }); 
}

Erro

"Call to undefined method [loginAttribute]"

Se eu remover a instrução if e loginAttribute e usar apenas $ rules ['nome de usuário'], ainda será possível registrar nomes com caracteres não alfanuméricos.

Consegui estender o novo código usando isso, mas não substituí o código existente.

questionAnswers(1)

yourAnswerToTheQuestion