-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from A4family/10-user-login-and-registration
User and admin Multi guard authentication
- Loading branch information
Showing
36 changed files
with
1,276 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\LoginRequest; | ||
use Illuminate\Foundation\Auth\AuthenticatesUsers; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class AdminController extends Controller | ||
{ | ||
//display login form | ||
public function index(){ | ||
return view('backend.admin-login'); | ||
} | ||
|
||
//login module | ||
public function login(LoginRequest $request){ | ||
try{ | ||
if(auth()->guard('admin')->attempt($request->only(['username', 'password']))){ | ||
return redirect(route('admin.dashboard')); | ||
} | ||
return redirect()->back()->with('message', 'Invalid Credentials'); | ||
}catch(\Exception $e){ | ||
return redirect()->back()->with('message', $e->getMessage()); | ||
} | ||
} | ||
|
||
|
||
//logout module | ||
public function logout(Request $request){ | ||
Auth::guard('admin')->logout(); | ||
return redirect('/admin-login'); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\LoginRequest; | ||
use App\Http\Requests\RegisterUserRequest; | ||
use App\Models\User; | ||
use Illuminate\Contracts\Session\Session; | ||
use Illuminate\Support\Facades\Session as LaravelSession; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Redirect; | ||
|
||
class UserController extends Controller | ||
{ | ||
public function userLoginForm(){ | ||
Redirect::setIntendedUrl(url()->previous()); | ||
return view('userend.login'); | ||
} | ||
|
||
|
||
//User Registration module | ||
public function registerUser(RegisterUserRequest $request){ | ||
try{ | ||
User::create([ | ||
'name' => $request->name, | ||
'username' => $request->username, | ||
'email' => $request->email, | ||
'password' => $request->password, | ||
]); | ||
return redirect()->back()->with('message', 'User Registered.'); | ||
}catch(\Exception $e){ | ||
return redirect()->back()->with('message', $e->getMessage()); | ||
} | ||
} | ||
|
||
//User Login module | ||
public function loginUser(LoginRequest $request){ | ||
try{ | ||
if(Auth::guard('web')->attempt(['username' => $request->username, 'password' => $request->password])){ | ||
return redirect()->intended(); | ||
} | ||
return redirect()->back()->with('message', 'Invalid Credentials'); | ||
|
||
}catch(\Exception $e){ | ||
return redirect()->back()->with('message', $e->getMessage()); | ||
} | ||
} | ||
|
||
//User logout module | ||
public function logoutUser(){ | ||
Auth::guard('web')->logout(); | ||
return redirect()->back(); | ||
} | ||
|
||
public function index(){ | ||
return view('userend.index'); | ||
} | ||
} |
Oops, something went wrong.