-
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.
Merge pull request #1777 from Ecodenl/feature/admin/confirm-user-email
Allow verifying emails by specific roles
- Loading branch information
Showing
11 changed files
with
91 additions
and
64 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
19 changes: 19 additions & 0 deletions
19
app/Http/Controllers/Cooperation/Admin/ActionController.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,19 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Cooperation\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Account; | ||
use App\Models\Cooperation; | ||
|
||
class ActionController extends Controller | ||
{ | ||
public function verifyEmail(Cooperation $cooperation, Account $account) | ||
{ | ||
$this->authorize('verifyEmail', $account); | ||
$account->update(['email_verified_at' => now()]); | ||
|
||
return redirect()->back() | ||
->with('success', __('cooperation/admin/cooperation/residents.index.table.columns.email-verified')); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Helpers\RoleHelper; | ||
use App\Models\Account; | ||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
|
||
class AccountPolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
public function verifyEmail(Account $account, Account $target): bool | ||
{ | ||
// A user can verify their own email, and certain roles can verify a (resident's) account's email also. | ||
return is_null($target->email_verified_at) && ($account->id === $target->id || ($account->user()->hasRole([ | ||
RoleHelper::ROLE_COACH, | ||
RoleHelper::ROLE_COORDINATOR, | ||
RoleHelper::ROLE_COOPERATION_ADMIN, | ||
])) && $target->user()->hasRole(RoleHelper::ROLE_RESIDENT)); | ||
} | ||
} |
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