-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: update pnpm dependencies * feat: dfo domain restriction * refactor: updates to registration and invitation - add domain validation * chore: update php dependencies * refactor: imporve cypress tests env, handle allowed domain
- Loading branch information
1 parent
f3144a0
commit 83e8dcf
Showing
24 changed files
with
933 additions
and
761 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 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
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/Http/Controllers/Auth/Traits/AuthorizedDomainTrait.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\Http\Controllers\Auth\Traits; | ||
|
||
use Illuminate\Validation\ValidationException; | ||
|
||
trait AuthorizedDomainTrait | ||
{ | ||
/** | ||
* Check if the email domain is part of the allowed domains | ||
* | ||
* @param string $email | ||
* @return bool | ||
*/ | ||
public function isEmailDomainAllowed(string $email): bool | ||
{ | ||
$allowedDomains = config('osp.allowed_registration_email_domains'); | ||
|
||
if ($allowedDomains) { | ||
$emailDomain = explode('@', $email)[1]; | ||
if (! in_array($emailDomain, $allowedDomains)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Validate the email domain and throw validation | ||
* exception if not allowed | ||
*/ | ||
public function validateEmailDomain(string $email): void | ||
{ | ||
if (! $this->isEmailDomainAllowed($email)) { | ||
throw ValidationException::withMessages([ | ||
'email' => __('Email domain not allowed') | ||
]); | ||
} | ||
} | ||
} |
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.