panique / huge

Simple user-authentication solution, embedded into a small framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[question] improve usability/ux - redirect requestPasswordReset_action/setNewPassword

elbenjaz opened this issue · comments

Hello guys,

About improve the usability/UX.
If a user fails in LoginController (::requestPasswordReset(), ::setNewPassword()),
He will be redirected to login and will have to "go back" using the browser to try again.

What do you think of changing the redirection depending on the method return?

Current source code (application/controller/LoginController.php):

    public function requestPasswordReset_action()
    {
        PasswordResetModel::requestPasswordReset(Request::post('user_name_or_email'), Request::post('captcha'));
        Redirect::to('login/index');
    }

    public function setNewPassword()
    {
        PasswordResetModel::setNewPassword(
            Request::post('user_name'), Request::post('user_password_reset_hash'),
            Request::post('user_password_new'), Request::post('user_password_repeat')
        );
        Redirect::to('login/index');
    }


Change:

    public function requestPasswordReset_action()
    {
        if (PasswordResetModel::requestPasswordReset(Request::post('user_name_or_email'), Request::post('captcha'))) {
            Redirect::to('login/index');
        } else {
            Redirect::to('login/requestPasswordReset');
        } 
    }

    public function setNewPassword()
    {
        if (PasswordResetModel::setNewPassword(
            Request::post('user_name'), Request::post('user_password_reset_hash'),
            Request::post('user_password_new'), Request::post('user_password_repeat')
        )) {
            Redirect::to('login/index');
        } else {
            Redirect::toPreviousPage();
        }
    }}

I'll go with #820 and so I would not agree with your changes on requestPasswordReset_action(). However I would agree with the changes on setNewPassword().