-
Notifications
You must be signed in to change notification settings - Fork 18
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 #1 from HijenHEK/form-validation
Form validation
- Loading branch information
Showing
43 changed files
with
729 additions
and
277,925 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
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,69 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\User; | ||
use Illuminate\Auth\Access\AuthorizationException; | ||
use Illuminate\Foundation\Auth\VerifiesEmails; | ||
use Illuminate\Http\Request; | ||
|
||
class VerificationController extends Controller | ||
{ | ||
// | ||
use VerifiesEmails; | ||
|
||
/** | ||
* Mark the authenticated user's email address as verified. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* | ||
*/ | ||
|
||
public function verify(Request $request) | ||
{ | ||
$user = User::findOrFail($request->route('id')); | ||
|
||
if ( | ||
!hash_equals((string) $request->route('id'), (string) $user->getKey()) | ||
|| !hash_equals((string) $request->route('hash'), sha1($user->getEmailForVerification())) | ||
) { | ||
|
||
return response()->json(['message' => 'Verification error ! Try again'], 500); | ||
} | ||
|
||
|
||
if ($user->hasVerifiedEmail()) { | ||
return response()->json(['message' => 'already verified !'], 200); | ||
} | ||
|
||
if ($user->markEmailAsVerified()) { | ||
return response()->json(['message' => 'email verified successfully !'], 200); | ||
} | ||
|
||
return response()->json(['verified' => true]); | ||
} | ||
|
||
|
||
/** | ||
* Resend the email verification notification. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
*/ | ||
public function resend(Request $request) | ||
{ | ||
|
||
$this->validate($request, ['id' => 'required']); | ||
|
||
$user = User::find($request->id); | ||
|
||
if (!$user) return response()->json(['message' => 'Verification error '], 500); | ||
|
||
|
||
if ($user->hasVerifiedEmail()) { | ||
return response()->json(['message' => 'already verified !'], 200); | ||
} | ||
|
||
$user->sendEmailVerificationNotification(); | ||
return response()->json(['message' => 'verification email has been resent !', 200]); | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Auth\Notifications\VerifyEmail; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Illuminate\Notifications\Notification; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Lang; | ||
use Illuminate\Support\Facades\URL; | ||
|
||
class VerifyEmailNotification extends verifyEmail implements ShouldQueue | ||
{ | ||
use Queueable; | ||
|
||
|
||
/** | ||
* Get the verification URL for the given notifiable. | ||
* | ||
* @param mixed $notifiable | ||
* @return string | ||
*/ | ||
protected function verificationUrl($notifiable) | ||
{ | ||
$url = URL::temporarySignedRoute( | ||
'verify', | ||
Carbon::now()->addMinutes(60), | ||
[ | ||
'id' => $notifiable->getKey(), | ||
'hash' => sha1($notifiable->getEmailForVerification()), | ||
] | ||
); | ||
|
||
return str_replace('/api', '', $url); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -114,4 +114,5 @@ | |
|
||
'password_timeout' => 10800, | ||
|
||
|
||
]; |
36 changes: 36 additions & 0 deletions
36
database/migrations/2021_04_26_093603_create_jobs_table.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,36 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateJobsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('jobs', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->string('queue')->index(); | ||
$table->longText('payload'); | ||
$table->unsignedTinyInteger('attempts'); | ||
$table->unsignedInteger('reserved_at')->nullable(); | ||
$table->unsignedInteger('available_at'); | ||
$table->unsignedInteger('created_at'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('jobs'); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Oops, something went wrong.