mtvbrianking / multi-auth

Laravel Multi-Authentication Package
https://github.com/mtvbrianking/multi-auth-diy
MIT License
179 stars 25 forks source link

View [auth.passwords.reset] not found. #4

Closed m4tt86 closed 6 years ago

m4tt86 commented 6 years ago

Hello, I created two guards, the first is named "admin" and the second "support". It works everithing well but whet I want to reset the password, I receving the following path on reset token route (password/reset/{token}')

View [auth.passwords.reset] not found.>

mtvbrianking commented 6 years ago

@m4tt86 I've have addressed the issue; implementing the reset password notification logic and published a release v1.1.4

Check it out, and feedback is appreciated...

m4tt86 commented 6 years ago

Hello, thank you. Unfortunately I still receive the same error "View [auth.passwords.reset] not found"

m4tt86 commented 6 years ago

You have to add the following code on ResetPasswordController.php

use Illuminate\Http\Request;

/** 
     * Display the password reset view for the given token.
     *
     * If no token is present, display the link request form.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  string|null  $token
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function showResetForm(Request $request, $token = null)
    {
        return view('{{singularSnake}}.auth.passwords.reset')->with(
            ['token' => $token, 'email' => $request->email]
        );
    }
mtvbrianking commented 6 years ago

Hope you updated to v1.1.4

If not; just run composerupdate-v in your project and confirm the version of the package your using...

And if you don't have any customization yet...

Run php artisan multi-auth:install{guard}-f

like php artisan multi-auth:installsellers-f

mtvbrianking commented 6 years ago

@m4tt86 you can do it the lengthy way...

#1 Notification :: app\Notifications\{{singularClass}}\Auth\ResetPassword.php

Create a custom notification for each guard

#2 Model :: app\{{singularClass}}.php

Use custom notification create above

use App\Notifications\{{singularClass}}\Auth\ResetPassword;
//...
public function sendPasswordResetNotification($token)
{
    $this->notify(new ResetPassword($token));
}

#3 Controller :: app\Controllers\{{singularClass}}\Auth\ResetPasswordController.php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

public function showResetForm(Request $request, $token = null)
{
    return view('{{singularSnake}}.auth.passwords.reset')->with(
        ['token' => $token, 'email' => $request->email]
    );
}

public function broker()
{
    return Password::broker('{{pluralSnake}}');
}

protected function guard()
{
    return Auth::guard('{{singularSnake}}');
}

Replace placeholders

Now these place holder are generated from the guard name you chose; say run ran

composer required bmatovu/multi-auth employees

Then the guard name is 'employees', therefore use the follow code to generate the final replacements.

{{pluralSnake}} :: str_plural(snake_case($name)) {{singularSnake}} :: str_singular(snake_case($name)) {{singularClass}} :: str_singular(studly_case($name))

m4tt86 commented 6 years ago

Thank you! Now it work!