Never use env() outside of config files. It will return null in production
env('GOOGLE_ENABLE', ''),
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I modified the code such a way that , after password reset it redirects to Login page instead of 'dashboard'. But before redirects I want to display a success message to the user 'Ssucess, your password has been updated, you may login now'. How it can be done?
Auth/ResetPasswordController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Setting;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Hash;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/login';
public function __construct()
{
if(Auth::check() && Auth::user()->role_id == 1){
$this->redirectTo = route('admin.dashboard');
} elseif(Auth::check() && Auth::user()->role_id == 2){
$this->redirectTo = route('user.dashboard');
}
$this->middleware('guest')->except('logout');
}
protected function redirectTo()
{
return '/user/dashboard';
}
public function showResetForm($token)
{
$config = DB::table('config')->get();
$settings = Setting::first();
return view('auth.passwords.reset', compact('config', 'token', 'settings'));
}
protected function resetPassword($user, $password)
{
$user->forceFill([
'password' => Hash::make($password),
'remember_token' => Str::random(60),
])->save();
}
}
Is there anthing do with this function?
vendor/laravel/ui/auth-backend/ResetsPasswords.php
protected function sendResetResponse(Request $request, $response)
{
if ($request->wantsJson()) {
return new JsonResponse(['message' => trans($response)], 200);
}
return redirect($this->redirectPath())
->with('status', trans($response));
}
it is not working, even though it sends status with redirect path
Please or to participate in this conversation.