Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
Change email validation on register and on login
Browse files Browse the repository at this point in the history
  • Loading branch information
WillianDamasceno committed Jun 8, 2024
1 parent aade7e3 commit 7946f93
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@

Route::group(['prefix' => 'auth'], function () {
Route::get('/register', function () {
$emailValidator = Validator::make(request()->all(), [
'email' => 'required|string|max:255|unique:users',
]);

if ($emailValidator->fails()) {
return response()->json(['data' => 'unique'], 200);
}

$validator = Validator::make(request()->all(), [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6',
'email' => 'required|string|max:255|unique:users',
'password' => 'required|string',
]);

if ($validator->fails()) {
Expand All @@ -33,8 +41,8 @@

Route::get('/login', function () {
$validator = Validator::make(request()->all(), [
'email' => 'required|string|email|max:255',
'password' => 'required|string|min:6',
'email' => 'required|string|max:255',
'password' => 'required|string',
]);

if ($validator->fails()) {
Expand Down

0 comments on commit 7946f93

Please sign in to comment.