In laravel 5.7 Logout functionality not working when im going to click logout button it show me this error
/var/www/html/orderManager/vendor/auth0/login/src/Auth0/Login/Auth0Service.php
$this->authApi = new Authentication($this->auth0Config['domain'],
$this->auth0Config['client_id']);
"Undefined index: domain"
web.php
Route::get('logout', 'HomeController#logout');
HomeController.php
public function logout() {
Auth::logout();
Session::flush();
return redirect('/login');
}
i remove this
"auth0/login": "~5.0"
from composer.json and update composer and its working..
In case you are doing a custom logout yourself, you can change your logout method to look like this
public function logout() {
auth()->logout();
return redirect('/login');
}
Then remove the auth0 package and try running composer update
Related
I'm working on my first laravel project in which I made an admin panel to make admin able to controller the website. I tried to login admin into dashboard and everything was fine, when I tried to log him out nothing works and the page was just reloading and redirect back.
Here is my logout button:
<a class="navbar-brand btn btn-primary btn-lg"
href="{{route('admin.logout'))}}"> log out</a>
My route:
Route::get('logout', 'LoginController#logout')->name('admin.logout');
And my controller:
use Illuminate\support\Facades\Auth;
public function logout(Request $request){
Auth::logout();
return redirect()->route('get.admin.login')
->with(['success'=>'logged out successfully']);
}
I used Auth::logout(); method from laravel official documentation, however it didn't work.
I hope I can find help.
as your using Auth::logout()inside that function
public function logout(Request $request) {
Auth::logout();
return redirect('/login');
}
here Auth:: will be null
so apply middleware to get Auth instance and then you can logout
Route::get('logout', 'LoginController#logout')->name('admin.logout')->middleware('auth');
You can use the following in your controller:
return redirect('login')->with(Auth::logout());
You can use below code, for logout the admin.
Auth::logout();
return redirect('/login');
I'm trying to flush the session then redirect the user to the "activate" view on logout, but it keeps taking me to "login" instead. Here's what I've tried in my web.php routes file:
Route::get('/logout', function () {
Session::flush();
Auth::logout();
return Redirect::to('activate');
});
How do I flush the cache and take users to the "activate" page on logout?
Change your route url, or except it from AuthController constructor :
public function __construct()
{
$this->middleware('auth', ['except' => ['logout']]);
}
without login If I give any URL's in the admin panel it is opening. How to solve it?
while login I am using,
$request->session()->put('userId', $user->userId);
In logout I am using,
$request->session()->forget('userId');
Route file,
Route::get('/addModule', function () {
return view('addModule');
});
How can I redirect to login screen. while am calling any admin panel URL's.
Just write this code in routes.php
Route::get('logout', function(Request $request) {
Auth::logout();
return redirect('/login');
});
Remember to import Auth class
I have implemented laravel 5.2 multi authentication.I have two guard web(default) and admin(created new). I have logged out user using Auth::logout() but I am not able to logout admin.
I tried to logout with Auth::guard('admin')->logout() and Auth::guard('admin')->user()->logout(). But its not working.
Try below code for logout method:
App/Http/Controllers/LoginRegisterCtrl.php
public function logout()
{
Auth::guard('web')->logout();
Auth::guard('admin')->logout();
}
Above code should work for you.
I'm trying simple logout functionality in laravel 5.2 but don't really understand where am I wrong. It would be great is someone can help.
here's Route
Route::get('logout', 'loginController#getLogout');
loginController getLogout method:
public function getLogout()
{
//$this->auth->logout();
Session::flush();
Auth::logout();
return redirect('/');
}
link in view that uses this function:
Logout
session store code:
$request->session()->put('name', $username['name']);
AuthController constructor:
public function __construct()
{
$this->middleware('guest', ['except' => ['logout', 'getLogout']]);
}
When user clicks on the logout link, it does redirect to root page but doesn't really destroy session or logout. It isn't requiring login to view pages (which it should).
I too had the same problem and i have rectified by Method 1 and i had reference using Method 2.
Method 1:
Route::get('auth/logout', 'Auth\AuthController#logout');
Or Method 2:
or in AuthController constructor add
public function __construct()
{
$this->middleware('guest', ['except' => ['logout', 'getLogout']]);
}
Hope so this will clear up your Error. I had the same problem and i did like this alone
Session Destroy must be used like this
Session::forget('name');
$request->session()->flush(); // in your Controller
Try to change the route in routes.php with this:
Route::get('logout', 'Auth\AuthController#logout');
And for the logout route I use:
{{ url('/logout') }}
Normally this works, if you need to use a different controller for something especial, try to use the:
$request->session()->flush()
in the controller.
Following the Laravel 5.2 documentation -> https://laravel.com/docs/5.2/session.
Other approximation, try to modify the order in your controller, maybe it will work. According to the doc, Auth:logout() will clean all user auth data, then you can clean the other session data.
public function getLogout()
{
//$this->auth->logout();
Auth::logout();
Session::flush();
return redirect('/');
}