-
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.
Browse files
Browse the repository at this point in the history
* feat: login using microsoft account * fix: do not show menu when empty * style: formatting * feat: migration to aad column * fix: change Request Type * fix: extra checks when login in with openid * feat: translated message * fix: more consistent naming * feat: changed routes + set email verified to null * feat: ajax call from login page * fix: return value email notification * feat: translate messages * fix: message translation * feat: block user if mail not send by you * feat: added translations to verify email * feat: create user now always has email * style: formatting * feat: added translations + removed unused view * feat: dont use event * style: formatting --------- Co-authored-by: Xander Schuurman <[email protected]>
- Loading branch information
Showing
18 changed files
with
311 additions
and
31 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
database/migrations/2023_07_14_150736_add_verified_email_column.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,28 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('cms_user', function (Blueprint $table) { | ||
$table->timestamp('email_verified_at')->nullable()->default(null); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('cms_user', function (Blueprint $table) { | ||
$table->dropColumn('email_verified_at'); | ||
}); | ||
} | ||
}; |
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,15 @@ | ||
{{-- blade-formatter-disable --}} | ||
<x-mail::message> | ||
# {{ __('siteboss::auth.verify_email_header') }} {{ config('app.name') }} | ||
|
||
{{ __('siteboss::auth.verify_email_link') }} | ||
|
||
<x-mail::button :url="$url"> | ||
{{ __('siteboss::auth.verify_email_button') }} | ||
</x-mail::button> | ||
|
||
Thanks,<br> | ||
{{ config('app.name') }} | ||
|
||
[<h4>{{__('siteboss::auth.verify_wrong_email')}}</h4>]({{$blockUrl}}) | ||
</x-mail::message> |
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,7 @@ | ||
@component('mail::message') | ||
|
||
<h4>De gebruiker met ID: {{ $user->id }} en e-mail: {{$user->email}} is geblokkeerd.</h4> | ||
<p>Dit is gegaan doormiddel van de blokkeer link in de verificatie email. | ||
</p> | ||
|
||
@endcomponent |
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,44 @@ | ||
<?php | ||
|
||
namespace NotFound\Framework\Auth\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\Auth\MustVerifyEmail; | ||
use Illuminate\Support\Facades\Redirect; | ||
|
||
class EnsureEmailIsVerified | ||
{ | ||
/** | ||
* Specify the redirect route for the middleware. | ||
* | ||
* @param string $route | ||
* @return string | ||
*/ | ||
public static function redirectTo($route) | ||
{ | ||
return static::class.':'.$route; | ||
} | ||
|
||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param string|null $redirectToRoute | ||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse|null | ||
*/ | ||
public function handle($request, Closure $next, $redirectToRoute = null) | ||
{ | ||
if (! $request->user() || | ||
($request->user() instanceof MustVerifyEmail && | ||
! $request->user()->hasVerifiedEmail())) { | ||
return [ | ||
'result' => 'error', | ||
'message' => __('siteboss::auth.verify_email'), | ||
'buttonText' => __('siteboss::auth.verify_email_resend'), | ||
'link' => route('verification.send', ['locale' => app()->getLocale()]), | ||
]; | ||
} | ||
|
||
return $next($request); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/Http/Controllers/Auth/EmailVerificationNotificationController.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,16 @@ | ||
<?php | ||
|
||
namespace NotFound\Framework\Http\Controllers\Auth; | ||
|
||
use Illuminate\Http\Request; | ||
use NotFound\Framework\Http\Controllers\Controller; | ||
|
||
class EmailVerificationNotificationController extends Controller | ||
{ | ||
public function __invoke(Request $request) | ||
{ | ||
$request->user()->sendEmailVerificationNotification(); | ||
|
||
return ['status' => 'ok', 'message' => __('siteboss::auth.verify_email_link_sent')]; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Http/Controllers/Auth/EmailVerificationPromptController.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,22 @@ | ||
<?php | ||
|
||
namespace NotFound\Framework\Http\Controllers\Auth; | ||
|
||
use Illuminate\Http\Request; | ||
use NotFound\Framework\Http\Controllers\Controller; | ||
use NotFound\Framework\Providers\RouteServiceProvider; | ||
|
||
class EmailVerificationPromptController extends Controller | ||
{ | ||
/** | ||
* Display the email verification prompt. | ||
* | ||
* @return mixed | ||
*/ | ||
public function __invoke(Request $request) | ||
{ | ||
return $request->user()->hasVerifiedEmail() | ||
? redirect()->intended(RouteServiceProvider::HOME) | ||
: view('siteboss::auth.verify-email'); | ||
} | ||
} |
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,48 @@ | ||
<?php | ||
|
||
namespace NotFound\Framework\Http\Controllers\Auth; | ||
|
||
use Illuminate\Auth\Access\AuthorizationException; | ||
use Illuminate\Auth\Events\Verified; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Mail; | ||
use NotFound\Framework\Http\Controllers\Controller; | ||
use NotFound\Framework\Mail\Admin\AccountBlocked; | ||
use NotFound\Framework\Models\CmsUser; | ||
|
||
class VerifyEmailController extends Controller | ||
{ | ||
/** | ||
* Mark the authenticated user's email address as verified. | ||
* | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function __invoke(Request $request) | ||
{ | ||
$user = CmsUser::find($request->route('id')); | ||
|
||
if ($request->query('block')) { | ||
$user->enabled = 0; | ||
$user->email_verified_at = null; | ||
$user->save(); | ||
|
||
Mail::to(env('SB_ADMIN_EMAIL'))->send(new AccountBlocked($user)); | ||
|
||
return ['status' => 'ok', 'message' => __('siteboss::auth.block_account_message')]; | ||
} | ||
|
||
if (! $user) { | ||
throw new AuthorizationException; | ||
} | ||
|
||
if (! hash_equals((string) $request->route('hash'), sha1($user->getEmailForVerification())) || ! $user->enabled) { | ||
throw new AuthorizationException; | ||
} | ||
|
||
if ($user->markEmailAsVerified()) { | ||
event(new Verified($user)); | ||
} | ||
|
||
return redirect('/siteboss')->with('verified', true); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace NotFound\Framework\Mail\Admin; | ||
|
||
use Illuminate\Mail\Mailable; | ||
use NotFound\Framework\Models\CmsUser; | ||
|
||
class AccountBlocked extends Mailable | ||
{ | ||
/** | ||
* Create a new message instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct( | ||
private CmsUser $user, | ||
) { | ||
} | ||
|
||
/** | ||
* Build the message. | ||
* | ||
* @return $this | ||
*/ | ||
public function build() | ||
{ | ||
return $this->markdown('siteboss::mail.admin.account-blocked') | ||
->subject('CMS: Account geblokkeerd') | ||
->with([ | ||
'user' => $this->user, | ||
]); | ||
} | ||
} |
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.