forked from apiato/apiato
-
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.
fix(verify email) fix verify email process
- Loading branch information
1 parent
30eb7ac
commit 4f03e51
Showing
7 changed files
with
90 additions
and
52 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
12 changes: 12 additions & 0 deletions
12
...Containers/AppSection/Authentication/Exceptions/InvalidEmailVerificationDataException.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,12 @@ | ||
<?php | ||
|
||
namespace App\Containers\AppSection\Authentication\Exceptions; | ||
|
||
use App\Ship\Parents\Exceptions\Exception; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class InvalidEmailVerificationDataException extends Exception | ||
{ | ||
protected $code = Response::HTTP_UNPROCESSABLE_ENTITY; | ||
protected $message = 'Invalid Email Verification Data Provided.'; | ||
} |
34 changes: 0 additions & 34 deletions
34
app/Containers/AppSection/Authentication/Tests/Unit/VerifyEmailActionTest.php
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
41 changes: 41 additions & 0 deletions
41
app/Containers/AppSection/Authentication/UI/API/Tests/Functional/VerifyEmailTest.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,41 @@ | ||
<?php | ||
|
||
namespace App\Containers\AppSection\Authentication\UI\API\Tests\Functional; | ||
|
||
use App\Containers\AppSection\Authentication\Notifications\EmailVerified; | ||
use App\Containers\AppSection\Authentication\UI\API\Tests\ApiTestCase; | ||
use App\Containers\AppSection\User\Models\User; | ||
use Illuminate\Support\Facades\Notification; | ||
|
||
/** | ||
* Class VerifyEmailTest. | ||
* | ||
* @group authentication | ||
* @group api | ||
*/ | ||
class VerifyEmailTest extends ApiTestCase | ||
{ | ||
protected string $endpoint = 'post@v1/email/verify/{id}/{hash}'; | ||
|
||
protected array $access = [ | ||
'roles' => '', | ||
'permissions' => '', | ||
]; | ||
|
||
public function testVerifyEmail(): void | ||
{ | ||
Notification::fake(); | ||
$unverifiedUser = User::factory()->unverified()->create(); | ||
// enable email verification | ||
config(['appSection-authentication.require_email_verification' => true]); | ||
|
||
$response = $this->injectId($unverifiedUser->id) | ||
->injectId(sha1($unverifiedUser->getEmailForVerification()), skipEncoding: true, replace: '{hash}') | ||
->makeCall(); | ||
|
||
$response->assertStatus(200); | ||
$unverifiedUser->refresh(); | ||
$this->assertTrue($unverifiedUser->hasVerifiedEmail()); | ||
Notification::assertSentTo($unverifiedUser, EmailVerified::class); | ||
} | ||
} |