-
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.
Admin side multiguard authentication: complete
- Loading branch information
1 parent
a350f24
commit 0c225ea
Showing
17 changed files
with
258 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\LoginFormValidator; | ||
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(LoginFormValidator $request){ | ||
try{ | ||
if(auth()->guard('admin')->attempt($request->only(['username', 'password']))): | ||
return redirect()->intended('/admin/dashboard'); | ||
else: | ||
return redirect()->back()->with('message', 'Invalid Credentials'); | ||
endif; | ||
}catch(\Exception $e){ | ||
return redirect()->back()->with('message', $e->getMessage()); | ||
} | ||
} | ||
|
||
|
||
//logout module | ||
public function logout(Request $request){ | ||
Auth::guard('admin')->logout(); | ||
$request->session()->invalidate(); | ||
$request->session()->regenerateToken(); | ||
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,48 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
// use Illuminate\Contracts\Auth\MustVerifyEmail; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Foundation\Auth\User as Authenticatable; | ||
use Illuminate\Notifications\Notifiable; | ||
use Laravel\Sanctum\HasApiTokens; | ||
|
||
class Admin extends Authenticatable | ||
{ | ||
use HasApiTokens, HasFactory, Notifiable; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array<int, string> | ||
*/ | ||
protected $table = 'admins'; | ||
protected $fillable = [ | ||
'name', | ||
'username', | ||
'email', | ||
'password', | ||
]; | ||
|
||
/** | ||
* The attributes that should be hidden for serialization. | ||
* | ||
* @var array<int, string> | ||
*/ | ||
protected $hidden = [ | ||
'password', | ||
'remember_token', | ||
]; | ||
|
||
/** | ||
* The attributes that should be cast. | ||
* | ||
* @var array<string, string> | ||
*/ | ||
protected $casts = [ | ||
'email_verified_at' => 'datetime', | ||
'password' => 'hashed', | ||
]; | ||
|
||
} |
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
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 |
---|---|---|
|
@@ -9,21 +9,31 @@ | |
use Illuminate\Database\Seeder; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class AdminDataDetails extends Seeder | ||
class UserSeeder extends Seeder | ||
|
||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
DB::table('users')->insert([ | ||
DB::table('admins')->insert([ | ||
'name' => 'Slymee', | ||
'username' => 'slymee', | ||
'email' => '[email protected]', | ||
'password' => Hash::make('slymee'), | ||
'created_at' => Carbon::now(), | ||
'updated_at' => Carbon::now(), | ||
]); | ||
|
||
DB::table('users')->insert([ | ||
'name' => 'MeeMee', | ||
'username' => 'meemee', | ||
'email' => '[email protected]', | ||
'password' => Hash::make('meemee'), | ||
'created_at' => Carbon::now(), | ||
'updated_at' => Carbon::now(), | ||
|
||
]); | ||
} | ||
} |
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
Empty file.
23 changes: 23 additions & 0 deletions
23
resources/views/userend/layouts/login-form-template.blade.php
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,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'> | ||
<title>Dashboard-Login</title> | ||
|
||
@vite(['resources/css/admin-login.css']) | ||
|
||
</head> | ||
<body> | ||
<section class="main-section"> | ||
<div class="form-banner"> | ||
<div class="img-place"> | ||
<img class="image" src="{{ URL('images/authenticate.jpg') }}" alt="Authenticate" srcset=""> | ||
</div> | ||
@yield('content') | ||
</div> | ||
</section> | ||
</body> | ||
</html> |
Oops, something went wrong.