Skip to content

Commit a2eaca3

Browse files
committed
initial commit
0 parents  commit a2eaca3

File tree

152 files changed

+17495
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+17495
-0
lines changed

README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<p align="center">
2+
<img src="https://github.com/beyondscript/Laravel-Multi-Auth/blob/main/public/assets/img/favicon.png" width="60" height="60" margin-left="auto" margin-right="auto" alt="Logo">
3+
<br>
4+
Laravel Multi Auth
5+
</p>
6+
7+
## About Laravel Multi Auth
8+
9+
Laravel Multi Auth is a web application which was designed by using HTML, CSS and JavaScript and developed by using PHP and Laravel framework.
10+
11+
This website was built for learning Laravel Multiple role based Authentication.
12+
13+
## How to use?
14+
15+
<strong>Step - 1:</strong>
16+
<br>
17+
Download or clone the repository
18+
19+
<strong>Step - 2:</strong>
20+
<br>
21+
Intall all the dependencies by running these commands "composer update" and "npm install"
22+
23+
<strong>Step - 3:</strong>
24+
<br>
25+
Copy the .env.example file from root directory to root directory then rename the copied file to .env
26+
27+
<strong>Step - 4:</strong>
28+
<br>
29+
Generate new application key by running the command "php artisan key:generate"
30+
31+
<strong>Step - 5:</strong>
32+
<br>
33+
Create a new database and import the laravelmultiauth.sql file
34+
35+
<strong>Step - 6:</strong>
36+
<br>
37+
Add the database details in the .env file by editing the .env file like below:
38+
39+
DB_DATABASE=database_name
40+
<br>
41+
DB_USERNAME=database_user_name
42+
<br>
43+
DB_PASSWORD=database_user_password
44+
45+
<strong>Step - 7:</strong>
46+
<br>
47+
Create a new email account and add the email account details in the .env file by editing the .env file like below:
48+
49+
MAIL_MAILER=smtp
50+
<br>
51+
MAIL_HOST=email_account_host.com
52+
<br>
53+
MAIL_PORT=465
54+
<br>
55+
MAIL_USERNAME=email_account_user_name
56+
<br>
57+
MAIL_PASSWORD=email_account_password
58+
<br>
59+
MAIL_ENCRYPTION=ssl
60+
<br>
61+
MAIL_FROM_ADDRESS=email_account
62+
<br>
63+
MAIL_FROM_NAME="${APP_NAME}"
64+
65+
<strong>Step - 8:</strong>
66+
<br>
67+
Add the application name in the .env file by editing the .env file like below:
68+
69+
APP_NAME="your_app_name"
70+
71+
<strong>Step - 9:</strong>
72+
<br>
73+
Add the application url in the .env file by editing the .env file like below:
74+
75+
APP_URL=your_application_url
76+
77+
<strong>Step - 10:</strong>
78+
<br>
79+
Add Facebook, GitHub and Google OAuth credentials in the .env file by editing the .env file like below:
80+
81+
FACEBOOK_CLIENT_ID=facebook_client_id
82+
<br>
83+
FACEBOOK_CLIENT_SECRET=facebook_client_secret
84+
85+
GITHUB_CLIENT_ID=github_client_id
86+
<br>
87+
GITHUB_CLIENT_SECRET=github_client_secret
88+
89+
GOOGLE_CLIENT_ID=google_client_id
90+
<br>
91+
GOOGLE_CLIENT_SECRET=google_client_secret
92+
93+
<strong>Step - 11:</strong>
94+
<br>
95+
Build the assets by running the command "npm run build"
96+
97+
<strong>Step - 12:</strong>
98+
<br>
99+
Delete the node_modules folder from the root directory
100+
101+
## Note
102+
103+
<strong>Facebook Callback/Redirect Url:</strong>
104+
<br>
105+
your_application_url/auth/facebook-callback
106+
107+
<strong>GitHub Callback/Redirect Url:</strong>
108+
<br>
109+
your_application_url/auth/github-callback
110+
111+
<strong>Google Callback/Redirect Url:</strong>
112+
<br>
113+
your_application_url/auth/google-callback
114+
115+
<strong>Admin Credentials:</strong>
116+
<br>
117+
Admin email is: [email protected]
118+
<br>
119+
Admin password is: 12345678
120+
121+
## When a problem is found?
122+
123+
Do not hesitate to message me when you found any problem.
124+
<br>
125+
<a href="https://www.facebook.com/engrmdnafiulislam/">Facebook</a>
126+
<br>
127+
<a href="https://www.instagram.com/engrmdnafiulislam/">Instagram</a>

app/Console/Kernel.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* Define the application's command schedule.
12+
*
13+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
14+
* @return void
15+
*/
16+
protected function schedule(Schedule $schedule)
17+
{
18+
// $schedule->command('inspire')->hourly();
19+
}
20+
21+
/**
22+
* Register the commands for the application.
23+
*
24+
* @return void
25+
*/
26+
protected function commands()
27+
{
28+
$this->load(__DIR__.'/Commands');
29+
30+
require base_path('routes/console.php');
31+
}
32+
}

app/Exceptions/Handler.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
use Illuminate\Routing\Exceptions\InvalidSignatureException;
8+
9+
class Handler extends ExceptionHandler
10+
{
11+
/**
12+
* A list of exception types with their corresponding custom log levels.
13+
*
14+
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
15+
*/
16+
protected $levels = [
17+
//
18+
];
19+
20+
/**
21+
* A list of the exception types that are not reported.
22+
*
23+
* @var array<int, class-string<\Throwable>>
24+
*/
25+
protected $dontReport = [
26+
//
27+
];
28+
29+
/**
30+
* A list of the inputs that are never flashed to the session on validation exceptions.
31+
*
32+
* @var array<int, string>
33+
*/
34+
protected $dontFlash = [
35+
'current_password',
36+
'password',
37+
'password_confirmation',
38+
];
39+
40+
/**
41+
* Register the exception handling callbacks for the application.
42+
*
43+
* @return void
44+
*/
45+
public function register()
46+
{
47+
$this->reportable(function (Throwable $e) {
48+
//
49+
});
50+
51+
$this->renderable(function (InvalidSignatureException $e) {
52+
if(request()->segment(1) === 'verify-email'){
53+
return redirect()->route('verification.notice')->with('error','Your request is not valid');
54+
}
55+
});
56+
57+
$this->renderable(function (\Exception $e) {
58+
if ($e->getPrevious() instanceof \Illuminate\Session\TokenMismatchException) {
59+
return redirect()->back()->with('error','Something went wrong');
60+
}
61+
});
62+
63+
$this->renderable(function (\Exception $e, $request) {
64+
if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
65+
if(env('APP_ENV') != 'local'){
66+
if (!$request->wantsJson() && !preg_match('/^www\./', $request->host())) {
67+
$wwwUrl = $request->getScheme() . '://www.' . $request->getHost() . $request->getRequestUri();
68+
69+
return redirect()->to($wwwUrl, 301);
70+
}
71+
}
72+
}
73+
});
74+
}
75+
}

app/Guards/CustomSessionGuard.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App\Guards;
4+
5+
use Illuminate\Auth\SessionGuard;
6+
use Illuminate\Support\Str;
7+
8+
class CustomSessionGuard extends SessionGuard
9+
{
10+
public function getRecallerName()
11+
{
12+
return 'remember_me_'.Str::slug(env('APP_NAME'));
13+
}
14+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Providers\RouteServiceProvider;
7+
use Illuminate\Foundation\Auth\ConfirmsPasswords;
8+
9+
class ConfirmPasswordController extends Controller
10+
{
11+
/*
12+
|--------------------------------------------------------------------------
13+
| Confirm Password Controller
14+
|--------------------------------------------------------------------------
15+
|
16+
| This controller is responsible for handling password confirmations and
17+
| uses a simple trait to include the behavior. You're free to explore
18+
| this trait and override any functions that require customization.
19+
|
20+
*/
21+
22+
use ConfirmsPasswords;
23+
24+
/**
25+
* Where to redirect users when the intended url fails.
26+
*
27+
* @var string
28+
*/
29+
protected $redirectTo = RouteServiceProvider::HOME;
30+
31+
/**
32+
* Create a new controller instance.
33+
*
34+
* @return void
35+
*/
36+
public function __construct()
37+
{
38+
$this->middleware('auth');
39+
}
40+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
7+
8+
class ForgotPasswordController extends Controller
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Password Reset Controller
13+
|--------------------------------------------------------------------------
14+
|
15+
| This controller is responsible for handling password reset emails and
16+
| includes a trait which assists in sending these notifications from
17+
| your application to your users. Feel free to explore this trait.
18+
|
19+
*/
20+
21+
use SendsPasswordResetEmails;
22+
}

0 commit comments

Comments
 (0)