-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve login accuracy event on Laravel>5 (#2642)
- Loading branch information
1 parent
54b48e5
commit 78871c1
Showing
46 changed files
with
1,031 additions
and
169 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 |
---|---|---|
|
@@ -60,3 +60,4 @@ package.json | |
packages.json | ||
package-lock.json | ||
yarn.lock | ||
cookies.txt |
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
58 changes: 58 additions & 0 deletions
58
tests/Frameworks/Laravel/Version_10_x/app/Http/Controllers/LoginTestController.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,58 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Auth\Events\Registered; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Http\RedirectResponse; | ||
use App\Providers\RouteServiceProvider; | ||
use App\Models\User; | ||
|
||
class LoginTestController extends Controller | ||
{ | ||
/** | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function auth(Request $request) | ||
{ | ||
$credentials = [ | ||
'email' => $request->get('email'), | ||
'password' => 'password', | ||
]; | ||
|
||
if (Auth::attempt($credentials)) { | ||
return response('Login successful', 200); | ||
} | ||
|
||
return response('Invalid credentials', 403); | ||
} | ||
|
||
public function register(Request $request): RedirectResponse | ||
{ | ||
$request->validate([ | ||
'name' => ['required'], | ||
'email' => ['required'], | ||
'password' => ['required'], | ||
]); | ||
|
||
$user = User::create([ | ||
'name' => $request->name, | ||
'email' => $request->email, | ||
'password' => Hash::make($request->password), | ||
]); | ||
|
||
event(new Registered($user)); | ||
|
||
Auth::login($user); | ||
|
||
return redirect('/simple'); | ||
} | ||
|
||
public function behind_auth() | ||
{ | ||
return "page behind auth"; | ||
} | ||
} |
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
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
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
58 changes: 58 additions & 0 deletions
58
tests/Frameworks/Laravel/Version_9_x/app/Http/Controllers/LoginTestController.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,58 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Auth\Events\Registered; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Http\RedirectResponse; | ||
use App\Providers\RouteServiceProvider; | ||
use App\Models\User; | ||
|
||
class LoginTestController extends Controller | ||
{ | ||
/** | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function auth(Request $request) | ||
{ | ||
$credentials = [ | ||
'email' => $request->get('email'), | ||
'password' => 'password', | ||
]; | ||
|
||
if (Auth::attempt($credentials)) { | ||
return response('Login successful', 200); | ||
} | ||
|
||
return response('Invalid credentials', 403); | ||
} | ||
|
||
public function register(Request $request): RedirectResponse | ||
{ | ||
$request->validate([ | ||
'name' => ['required'], | ||
'email' => ['required'], | ||
'password' => ['required'], | ||
]); | ||
|
||
$user = User::create([ | ||
'name' => $request->name, | ||
'email' => $request->email, | ||
'password' => Hash::make($request->password), | ||
]); | ||
|
||
event(new Registered($user)); | ||
|
||
Auth::login($user); | ||
|
||
return redirect('/simple'); | ||
} | ||
|
||
public function behind_auth() | ||
{ | ||
return "page behind auth"; | ||
} | ||
} |
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
Oops, something went wrong.