From 0ac63604f4744211560a8a5f4106fbd6d7510605 Mon Sep 17 00:00:00 2001 From: keeama13 Date: Fri, 15 Sep 2023 13:39:49 +0200 Subject: [PATCH 01/13] feat: block account route --- routes/api.php | 4 ++ .../Auth/VerifyEmailController.php | 39 ++++++++++++++++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/routes/api.php b/routes/api.php index 3d69b010..ec2229bf 100644 --- a/routes/api.php +++ b/routes/api.php @@ -33,6 +33,10 @@ ->middleware([ValidateSignature::class, 'throttle:6,1']) ->name('siteboss.verification.verify'); + Route::get('email/verify/block/{id}/{hash}', [VerifyEmailController::class, 'block']) + ->middleware([ValidateSignature::class, 'throttle:6,1']) + ->name('siteboss.verification.block'); + // Unauthenticated routes Route::namespace('Forms')->group(function () { Route::post('forms/{form:id}/{langurl}', [DataController::class, 'create'])->middleware(ProtectAgainstSpam::class)->name('formbuilder.post'); diff --git a/src/Http/Controllers/Auth/VerifyEmailController.php b/src/Http/Controllers/Auth/VerifyEmailController.php index d263e74b..b836dfba 100644 --- a/src/Http/Controllers/Auth/VerifyEmailController.php +++ b/src/Http/Controllers/Auth/VerifyEmailController.php @@ -5,7 +5,10 @@ use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Events\Verified; use Illuminate\Http\Request; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\URL; use NotFound\Framework\Http\Controllers\Controller; use NotFound\Framework\Mail\Admin\AccountBlocked; use NotFound\Framework\Models\CmsUser; @@ -22,13 +25,20 @@ 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(); + $link = URL::temporarySignedRoute( + 'siteboss.verification.block', + Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), + [ + 'id' => $request->route('id'), + 'hash' => $request->route('hash'), + ]); - Mail::to(env('SB_ADMIN_EMAIL'))->send(new AccountBlocked($user)); - - return ['status' => 'ok', 'message' => __('siteboss::auth.block_account_message')]; + return [ + 'result' => 'error', + 'message' => 'weet je zeker dat je wilt blokekN?', + 'buttonText' => 'blokkeer email', + 'link' => $link, + ]; } if (! $user) { @@ -45,4 +55,21 @@ public function __invoke(Request $request) return redirect('/siteboss')->with('verified', true); } + + public function block(Request $request, CmsUser $user) + { + dd($request->route('hash'), $user->getEmailForVerification()); + + if (! hash_equals((string) $request->route('hash'), sha1($user->getEmailForVerification()))) { + throw new AuthorizationException; + } + + $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')]; + } } From 6ded6cb653ec0739af72e7d5756f1ce27fd71652 Mon Sep 17 00:00:00 2001 From: keeama13 Date: Tue, 19 Sep 2023 13:03:25 +0200 Subject: [PATCH 02/13] feat: messages --- lang/en/auth.php | 3 +++ lang/nl/auth.php | 3 +++ src/Http/Controllers/Auth/VerifyEmailController.php | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lang/en/auth.php b/lang/en/auth.php index fd25c37b..0c54f258 100644 --- a/lang/en/auth.php +++ b/lang/en/auth.php @@ -22,6 +22,9 @@ 'verify_email_button' => 'Verify email', 'verify_email_resend' => 'Resend verification email', 'verify_email_link_sent' => 'A fresh verification link has been sent to your email address.', + 'verify_email_success' => 'Account successfully verified.', 'verify_wrong_email' => 'Click here to block this attempt if you were not the one who tried to login.', + 'verify_block_action' => 'Are you sure you want to block this account?', + 'block_account_button' => 'Block account', 'block_account_message' => 'The account has been blocked.', ]; diff --git a/lang/nl/auth.php b/lang/nl/auth.php index 1c76b973..e26c87b1 100644 --- a/lang/nl/auth.php +++ b/lang/nl/auth.php @@ -21,6 +21,9 @@ 'verify_email_link' => 'Klik op onderstaande link om je e-mailadres te bevestigen.', 'verify_email_resend' => 'Verificatiemail opnieuw verzenden', 'verify_email_link_sent' => 'Er is een nieuwe verificatielink naar jouw e-mailadres verzonden.', + 'verify_email_success' => 'Account successvol geverifieerd.', 'verify_wrong_email' => 'Heb je zelf niet geprobeerd in te loggen? Klik dan hier om deze poging te blokkeren.', + 'verify_block_action' => 'Weet je zeker dat je dit account wilt blokkeren?', + 'block_account_button' => 'Blokkeer account', 'block_account_message' => 'Account succesvol geblokkeerd.', ]; diff --git a/src/Http/Controllers/Auth/VerifyEmailController.php b/src/Http/Controllers/Auth/VerifyEmailController.php index b836dfba..b5578cf1 100644 --- a/src/Http/Controllers/Auth/VerifyEmailController.php +++ b/src/Http/Controllers/Auth/VerifyEmailController.php @@ -35,8 +35,8 @@ public function __invoke(Request $request) return [ 'result' => 'error', - 'message' => 'weet je zeker dat je wilt blokekN?', - 'buttonText' => 'blokkeer email', + 'message' => __('siteboss::auth.verify_block_account'), + 'buttonText' => __('siteboss::auth.block_account_button'), 'link' => $link, ]; } @@ -53,7 +53,7 @@ public function __invoke(Request $request) event(new Verified($user)); } - return redirect('/siteboss')->with('verified', true); + return ['status' => 'ok', 'message' => __('siteboss::auth.verify_email_success')]; } public function block(Request $request, CmsUser $user) From 7e40f535cd7c30c3921a7d519c416a3774a6151c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Fri, 17 Nov 2023 13:45:03 +0100 Subject: [PATCH 03/13] fix: add nullable (#163) --- .../2023_10_25_171457_add_created_at_to_menu_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php b/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php index c5c9f83b..3556e367 100644 --- a/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php +++ b/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php @@ -12,7 +12,7 @@ public function up(): void { Schema::table('menu', function (Blueprint $table) { - $table->timestamp('created_at'); + $table->timestamp('created_at')->nullable(); }); } From b12e50265ddc23cf5bda4d1d0e651b9096bee36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Wed, 22 Nov 2023 14:32:25 +0100 Subject: [PATCH 04/13] feat: set null for searchitem (#166) * fix: fallback to null for SearchItem * style: formatting --- src/Services/Indexer/SearchItem.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Services/Indexer/SearchItem.php b/src/Services/Indexer/SearchItem.php index 38b70e2d..52cd12ca 100644 --- a/src/Services/Indexer/SearchItem.php +++ b/src/Services/Indexer/SearchItem.php @@ -17,9 +17,9 @@ final class SearchItem private bool $inSitemap = true; - private ?DateTime $publicationDate; + private ?DateTime $publicationDate = null; - private ?DateTime $lastUpdated; + private ?DateTime $lastUpdated = null; private int $priority = 1; @@ -146,12 +146,7 @@ public function content(): ?string */ public function publicationDate(): ?string { - $time = $this->publicationDate ?? $this->lastUpdated; - if ($time === null) { - return null; - } - - return $time->format(DateTime::ATOM); + return $this->toDateString($this->publicationDate ?? $this->lastUpdated); } /** @@ -162,12 +157,7 @@ public function publicationDate(): ?string */ public function lastUpdated(): ?string { - $time = $this->lastUpdated ?? $this->publicationDate; - if ($time === null) { - return null; - } - - return $time->format(DateTime::ATOM); + return $this->toDateString($this->lastUpdated ?? $this->publicationDate); } public function customValues(): ?array @@ -189,4 +179,13 @@ public function sitemap(): bool { return $this->inSitemap; } + + private function toDateString(?DateTime $date): ?string + { + if ($date === null) { + return null; + } + + return $date->format(DateTime::ATOM); + } } From 5e6a9b28cc2691d89abfb7bea058d709ce001450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Wed, 22 Nov 2023 23:28:30 +0100 Subject: [PATCH 05/13] fix: only add column when it doesn't exist (#167) * fix: only add column when it doesn't exist * style: formatting --- .../2023_10_25_171457_add_created_at_to_menu_table.php | 3 +++ src/Services/Editor/FieldsProperties.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php b/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php index 3556e367..c7fc39fe 100644 --- a/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php +++ b/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php @@ -11,6 +11,9 @@ */ public function up(): void { + if (Schema::hasColumn('menu', 'created_at')) { + return; + } Schema::table('menu', function (Blueprint $table) { $table->timestamp('created_at')->nullable(); }); diff --git a/src/Services/Editor/FieldsProperties.php b/src/Services/Editor/FieldsProperties.php index 806dfc4e..b2967609 100644 --- a/src/Services/Editor/FieldsProperties.php +++ b/src/Services/Editor/FieldsProperties.php @@ -150,7 +150,7 @@ private function addLayoutFields(array $properties, LayoutForm &$form) // $checkboxField->setValue(true); // } else { $checkboxField->setValue(false); - // } + // } } else { $checkboxField->setValue($value ?? false); } From d131a1d3145a3405dd4251a6863ef0396a4fc5a4 Mon Sep 17 00:00:00 2001 From: keeama13 Date: Fri, 9 Feb 2024 11:43:59 +0100 Subject: [PATCH 06/13] feat: dd removed --- src/Http/Controllers/Auth/VerifyEmailController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Http/Controllers/Auth/VerifyEmailController.php b/src/Http/Controllers/Auth/VerifyEmailController.php index b5578cf1..fc3dfd05 100644 --- a/src/Http/Controllers/Auth/VerifyEmailController.php +++ b/src/Http/Controllers/Auth/VerifyEmailController.php @@ -56,9 +56,13 @@ public function __invoke(Request $request) return ['status' => 'ok', 'message' => __('siteboss::auth.verify_email_success')]; } - public function block(Request $request, CmsUser $user) + public function block(Request $request) { - dd($request->route('hash'), $user->getEmailForVerification()); + $user = CmsUser::find($request->route('id')); + + if (! $user) { + throw new AuthorizationException; + } if (! hash_equals((string) $request->route('hash'), sha1($user->getEmailForVerification()))) { throw new AuthorizationException; From 1dd1343d6f370ef2607bb3a330927dde55ac9532 Mon Sep 17 00:00:00 2001 From: Rene Date: Fri, 9 Feb 2024 12:27:45 +0100 Subject: [PATCH 07/13] feat: add admin e-mail to config --- config/siteboss.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config/siteboss.php b/config/siteboss.php index ec55bdad..ec04184e 100644 --- a/config/siteboss.php +++ b/config/siteboss.php @@ -49,4 +49,15 @@ 'export_retain_ids' => env('SB_EXPORT_RETAIN_IDS', false), + /* + |-------------------------------------------------------------------------- + | Admin email + |-------------------------------------------------------------------------- + | + | Email address to send admin notifications to. + | + */ + + 'admin_email' => env('SB_ADMIN_EMAIL', null), + ]; From ec367d53988b993aa5542962729169bd090492fe Mon Sep 17 00:00:00 2001 From: Rene Date: Fri, 9 Feb 2024 12:35:00 +0100 Subject: [PATCH 08/13] feat: publish css file --- resources/css/siteboss.css | 698 +++++++++++++++++++++++++++++++ src/FrameworkServiceProvider.php | 1 + 2 files changed, 699 insertions(+) create mode 100644 resources/css/siteboss.css diff --git a/resources/css/siteboss.css b/resources/css/siteboss.css new file mode 100644 index 00000000..788d069c --- /dev/null +++ b/resources/css/siteboss.css @@ -0,0 +1,698 @@ +/* Global variables. */ +:root, +::backdrop { + /* Set sans-serif & mono fonts */ + --sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir, + "Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica, + "Helvetica Neue", sans-serif; + --mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace; + --standard-border-radius: 5px; + + /* Default (light) theme */ + --bg: #fff; + --accent-bg: #f5f7ff; + --text: #212121; + --text-light: #585858; + --border: #898EA4; + --accent: #0d47a1; + --accent-hover: #1266e2; + --accent-text: var(--bg); + --code: #d81b60; + --preformatted: #444; + --marked: #ffdd33; + --disabled: #efefef; +} + +/* Dark theme */ +@media (prefers-color-scheme: dark) { + :root, + ::backdrop { + color-scheme: dark; + --bg: #212121; + --accent-bg: #2b2b2b; + --text: #dcdcdc; + --text-light: #ababab; + --accent: #ffb300; + --accent-hover: #ffe099; + --accent-text: var(--bg); + --code: #f06292; + --preformatted: #ccc; + --disabled: #111; + } + /* Add a bit of transparency so light media isn't so glaring in dark mode */ + img, + video { + opacity: 0.8; + } +} + +/* Reset box-sizing */ +*, *::before, *::after { + box-sizing: border-box; +} + +/* Reset default appearance */ +textarea, +select, +input, +progress { + appearance: none; + -webkit-appearance: none; + -moz-appearance: none; +} + +html { + /* Set the font globally */ + font-family: var(--sans-font); + scroll-behavior: smooth; +} + +/* Make the body a nice central block */ +body { + color: var(--text); + background-color: var(--bg); + font-size: 1.15rem; + line-height: 1.5; + display: grid; + grid-template-columns: 1fr min(45rem, 90%) 1fr; + margin: 0; +} +body > * { + grid-column: 2; +} + +/* Make the header bg full width, but the content inline with body */ +body > header { + background-color: var(--accent-bg); + border-bottom: 1px solid var(--border); + text-align: center; + padding: 0 0.5rem 2rem 0.5rem; + grid-column: 1 / -1; +} + +body > header > *:only-child { + margin-block-start: 2rem; +} + +body > header h1 { + max-width: 1200px; + margin: 1rem auto; +} + +body > header p { + max-width: 40rem; + margin: 1rem auto; +} + +/* Add a little padding to ensure spacing is correct between content and header > nav */ +main { + padding-top: 1.5rem; +} + +body > footer { + margin-top: 4rem; + padding: 2rem 1rem 1.5rem 1rem; + color: var(--text-light); + font-size: 0.9rem; + text-align: center; + border-top: 1px solid var(--border); +} + +/* Format headers */ +h1 { + font-size: 3rem; +} + +h2 { + font-size: 2.6rem; + margin-top: 3rem; +} + +h3 { + font-size: 2rem; + margin-top: 3rem; +} + +h4 { + font-size: 1.44rem; +} + +h5 { + font-size: 1.15rem; +} + +h6 { + font-size: 0.96rem; +} + +p { + margin: 1.5rem 0; +} + +/* Prevent long strings from overflowing container */ +p, h1, h2, h3, h4, h5, h6 { + overflow-wrap: break-word; +} + +/* Fix line height when title wraps */ +h1, +h2, +h3 { + line-height: 1.1; +} + +/* Reduce header size on mobile */ +@media only screen and (max-width: 720px) { + h1 { + font-size: 2.5rem; + } + + h2 { + font-size: 2.1rem; + } + + h3 { + font-size: 1.75rem; + } + + h4 { + font-size: 1.25rem; + } +} + +/* Format links & buttons */ +a, +a:visited { + color: var(--accent); +} + +a:hover { + text-decoration: none; +} + +button, +.button, +a.button, /* extra specificity to override a */ +input[type="submit"], +input[type="reset"], +input[type="button"], +label[type="button"] { + border: 1px solid var(--accent); + background-color: var(--accent); + color: var(--accent-text); + padding: 0.5rem 0.9rem; + text-decoration: none; + line-height: normal; +} + +.button[aria-disabled="true"], +input:disabled, +textarea:disabled, +select:disabled, +button[disabled] { + cursor: not-allowed; + background-color: var(--disabled); + border-color: var(--disabled); + color: var(--text-light); +} + +input[type="range"] { + padding: 0; +} + +/* Set the cursor to '?' on an abbreviation and style the abbreviation to show that there is more information underneath */ +abbr[title] { + cursor: help; + text-decoration-line: underline; + text-decoration-style: dotted; +} + +button:enabled:hover, +.button:not([aria-disabled="true"]):hover, +input[type="submit"]:enabled:hover, +input[type="reset"]:enabled:hover, +input[type="button"]:enabled:hover, +label[type="button"]:hover { + background-color: var(--accent-hover); + border-color: var(--accent-hover); + cursor: pointer; +} + +.button:focus-visible, +button:focus-visible:where(:enabled), +input:enabled:focus-visible:where( + [type="submit"], + [type="reset"], + [type="button"] +) { + outline: 2px solid var(--accent); + outline-offset: 1px; +} + +/* Format navigation */ +header > nav { + font-size: 1rem; + line-height: 2; + padding: 1rem 0 0 0; +} + +/* Use flexbox to allow items to wrap, as needed */ +header > nav ul, +header > nav ol { + align-content: space-around; + align-items: center; + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + list-style-type: none; + margin: 0; + padding: 0; +} + +/* List items are inline elements, make them behave more like blocks */ +header > nav ul li, +header > nav ol li { + display: inline-block; +} + +header > nav a, +header > nav a:visited { + margin: 0 0.5rem 1rem 0.5rem; + border: 1px solid var(--border); + border-radius: var(--standard-border-radius); + color: var(--text); + display: inline-block; + padding: 0.1rem 1rem; + text-decoration: none; +} + +header > nav a:hover, +header > nav a.current, +header > nav a[aria-current="page"] { + border-color: var(--accent); + color: var(--accent); + cursor: pointer; +} + +/* Reduce nav side on mobile */ +@media only screen and (max-width: 720px) { + header > nav a { + border: none; + padding: 0; + text-decoration: underline; + line-height: 1; + } +} + +/* Consolidate box styling */ +aside, details, pre, progress { + background-color: var(--accent-bg); + border: 1px solid var(--border); + border-radius: var(--standard-border-radius); + margin-bottom: 1rem; +} + +aside { + font-size: 1rem; + width: 30%; + padding: 0 15px; + margin-inline-start: 15px; + float: right; +} +*[dir="rtl"] aside { + float: left; +} + +/* Make aside full-width on mobile */ +@media only screen and (max-width: 720px) { + aside { + width: 100%; + float: none; + margin-inline-start: 0; + } +} + +article, fieldset, dialog { + border: 1px solid var(--border); + padding: 1rem; + border-radius: var(--standard-border-radius); + margin-bottom: 1rem; +} + +article h2:first-child, +section h2:first-child { + margin-top: 1rem; +} + +section { + border-top: 1px solid var(--border); + border-bottom: 1px solid var(--border); + padding: 2rem 1rem; + margin: 3rem 0; +} + +/* Don't double separators when chaining sections */ +section + section, +section:first-child { + border-top: 0; + padding-top: 0; +} + +section:last-child { + border-bottom: 0; + padding-bottom: 0; +} + +details { + padding: 0.7rem 1rem; +} + +summary { + cursor: pointer; + font-weight: bold; + padding: 0.7rem 1rem; + margin: -0.7rem -1rem; + word-break: break-all; +} + +details[open] > summary + * { + margin-top: 0; +} + +details[open] > summary { + margin-bottom: 0.5rem; +} + +details[open] > :last-child { + margin-bottom: 0; +} + +/* Format tables */ +table { + border-collapse: collapse; + margin: 1.5rem 0; +} + +figure > table { + width: max-content; +} + +td, +th { + border: 1px solid var(--border); + text-align: start; + padding: 0.5rem; +} + +th { + background-color: var(--accent-bg); + font-weight: bold; +} + +tr:nth-child(even) { + /* Set every other cell slightly darker. Improves readability. */ + background-color: var(--accent-bg); +} + +table caption { + font-weight: bold; + margin-bottom: 0.5rem; +} + +/* Format forms */ +textarea, +select, +input, +button, +.button { + font-size: inherit; + font-family: inherit; + padding: 0.5rem; + margin-bottom: 0.5rem; + border-radius: var(--standard-border-radius); + box-shadow: none; + max-width: 100%; + display: inline-block; +} +textarea, +select, +input { + color: var(--text); + background-color: var(--bg); + border: 1px solid var(--border); +} +label { + display: block; +} +textarea:not([cols]) { + width: 100%; +} + +/* Add arrow to drop-down */ +select:not([multiple]) { + background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%), + linear-gradient(135deg, var(--text) 51%, transparent 49%); + background-position: calc(100% - 15px), calc(100% - 10px); + background-size: 5px 5px, 5px 5px; + background-repeat: no-repeat; + padding-inline-end: 25px; +} +*[dir="rtl"] select:not([multiple]) { + background-position: 10px, 15px; +} + +/* checkbox and radio button style */ +input[type="checkbox"], +input[type="radio"] { + vertical-align: middle; + position: relative; + width: min-content; +} + +input[type="checkbox"] + label, +input[type="radio"] + label { + display: inline-block; +} + +input[type="radio"] { + border-radius: 100%; +} + +input[type="checkbox"]:checked, +input[type="radio"]:checked { + background-color: var(--accent); +} + +input[type="checkbox"]:checked::after { + /* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */ + content: " "; + width: 0.18em; + height: 0.32em; + border-radius: 0; + position: absolute; + top: 0.05em; + left: 0.17em; + background-color: transparent; + border-right: solid var(--bg) 0.08em; + border-bottom: solid var(--bg) 0.08em; + font-size: 1.8em; + transform: rotate(45deg); +} +input[type="radio"]:checked::after { + /* creates a colored circle for the checked radio button */ + content: " "; + width: 0.25em; + height: 0.25em; + border-radius: 100%; + position: absolute; + top: 0.125em; + background-color: var(--bg); + left: 0.125em; + font-size: 32px; +} + +/* Makes input fields wider on smaller screens */ +@media only screen and (max-width: 720px) { + textarea, + select, + input { + width: 100%; + } +} + +/* Set a height for color input */ +input[type="color"] { + height: 2.5rem; + padding: 0.2rem; +} + +/* do not show border around file selector button */ +input[type="file"] { + border: 0; +} + +/* Misc body elements */ +hr { + border: none; + height: 1px; + background: var(--border); + margin: 1rem auto; +} + +mark { + padding: 2px 5px; + border-radius: var(--standard-border-radius); + background-color: var(--marked); + color: black; +} + +mark a { + color: #0d47a1; +} + +img, +video { + max-width: 100%; + height: auto; + border-radius: var(--standard-border-radius); +} + +figure { + margin: 0; + display: block; + overflow-x: auto; +} + +figcaption { + text-align: center; + font-size: 0.9rem; + color: var(--text-light); + margin-bottom: 1rem; +} + +blockquote { + margin-inline-start: 2rem; + margin-inline-end: 0; + margin-block: 2rem; + padding: 0.4rem 0.8rem; + border-inline-start: 0.35rem solid var(--accent); + color: var(--text-light); + font-style: italic; +} + +cite { + font-size: 0.9rem; + color: var(--text-light); + font-style: normal; +} + +dt { + color: var(--text-light); +} + +/* Use mono font for code elements */ +code, +pre, +pre span, +kbd, +samp { + font-family: var(--mono-font); + color: var(--code); +} + +kbd { + color: var(--preformatted); + border: 1px solid var(--preformatted); + border-bottom: 3px solid var(--preformatted); + border-radius: var(--standard-border-radius); + padding: 0.1rem 0.4rem; +} + +pre { + padding: 1rem 1.4rem; + max-width: 100%; + overflow: auto; + color: var(--preformatted); +} + +/* Fix embedded code within pre */ +pre code { + color: var(--preformatted); + background: none; + margin: 0; + padding: 0; +} + +/* Progress bars */ +/* Declarations are repeated because you */ +/* cannot combine vendor-specific selectors */ +progress { + width: 100%; +} + +progress:indeterminate { + background-color: var(--accent-bg); +} + +progress::-webkit-progress-bar { + border-radius: var(--standard-border-radius); + background-color: var(--accent-bg); +} + +progress::-webkit-progress-value { + border-radius: var(--standard-border-radius); + background-color: var(--accent); +} + +progress::-moz-progress-bar { + border-radius: var(--standard-border-radius); + background-color: var(--accent); + transition-property: width; + transition-duration: 0.3s; +} + +progress:indeterminate::-moz-progress-bar { + background-color: var(--accent-bg); +} + +dialog { + max-width: 40rem; + margin: auto; +} + +dialog::backdrop { + background-color: var(--bg); + opacity: 0.8; +} + +@media only screen and (max-width: 720px) { + dialog { + max-width: 100%; + margin: auto 1em; + } +} + +/* Superscript & Subscript */ +/* Prevent scripts from affecting line-height. */ +sup, sub { + vertical-align: baseline; + position: relative; +} + +sup { + top: -0.4em; +} + +sub { + top: 0.3em; +} + +/* Classes for notices */ +.notice { + background: var(--accent-bg); + border: 2px solid var(--border); + border-radius: var(--standard-border-radius); + padding: 1.5rem; + margin: 2rem 0; +} diff --git a/src/FrameworkServiceProvider.php b/src/FrameworkServiceProvider.php index 91925468..f6d4935d 100644 --- a/src/FrameworkServiceProvider.php +++ b/src/FrameworkServiceProvider.php @@ -35,6 +35,7 @@ public function boot(): void __DIR__.'/../config/database.php' => config_path('database.php'), __DIR__.'/../config/indexer.php' => config_path('indexer.php'), __DIR__.'/../config/laravellocalization.php' => config_path('laravellocalization.php'), + __DIR__.'/../resources/css/siteboss.css' => public_path('assets/static/siteboss.css'), __DIR__.'/Providers/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), ], 'siteboss-framework'); From 2e51ad16ebc5dd678e4d97f60c96ea0cb0317e96 Mon Sep 17 00:00:00 2001 From: Rene Date: Fri, 9 Feb 2024 12:40:41 +0100 Subject: [PATCH 09/13] feat: update block template --- lang/en/auth.php | 6 ++- lang/nl/auth.php | 8 ++- resources/views/components/info.blade.php | 50 +++++++++++++++++++ resources/views/pages/block-account.blade.php | 7 +++ .../Auth/VerifyEmailController.php | 11 ++-- 5 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 resources/views/components/info.blade.php create mode 100644 resources/views/pages/block-account.blade.php diff --git a/lang/en/auth.php b/lang/en/auth.php index 0c54f258..ca942e70 100644 --- a/lang/en/auth.php +++ b/lang/en/auth.php @@ -24,7 +24,9 @@ 'verify_email_link_sent' => 'A fresh verification link has been sent to your email address.', 'verify_email_success' => 'Account successfully verified.', 'verify_wrong_email' => 'Click here to block this attempt if you were not the one who tried to login.', - 'verify_block_action' => 'Are you sure you want to block this account?', - 'block_account_button' => 'Block account', 'block_account_message' => 'The account has been blocked.', + 'verify_block_account_title' => 'Block account?', + 'verify_block_account_message' => 'Are you sure you want to block this account? You will not be able to login to SiteBoss. An administrator can unblock your account.', + 'verify_block_account_button' => 'Block account', + ]; diff --git a/lang/nl/auth.php b/lang/nl/auth.php index e26c87b1..3942e6eb 100644 --- a/lang/nl/auth.php +++ b/lang/nl/auth.php @@ -22,8 +22,12 @@ 'verify_email_resend' => 'Verificatiemail opnieuw verzenden', 'verify_email_link_sent' => 'Er is een nieuwe verificatielink naar jouw e-mailadres verzonden.', 'verify_email_success' => 'Account successvol geverifieerd.', + 'verify_wrong_email' => 'Heb je zelf niet geprobeerd in te loggen? Klik dan hier om deze poging te blokkeren.', - 'verify_block_action' => 'Weet je zeker dat je dit account wilt blokkeren?', - 'block_account_button' => 'Blokkeer account', + + 'verify_block_account_title' => 'Account blokkeren?', + 'verify_block_account_message' => 'Wil je voor de zekerheid jouw account blokkeren? Je kunt dan niet meer inloggen op SiteBoss. Een administrator kan jouw account weer deblokkeren.', + 'verify_block_account_button' => 'Blokkeer account', + 'block_account_message' => 'Account succesvol geblokkeerd.', ]; diff --git a/resources/views/components/info.blade.php b/resources/views/components/info.blade.php new file mode 100644 index 00000000..58bc0fca --- /dev/null +++ b/resources/views/components/info.blade.php @@ -0,0 +1,50 @@ + + + + + {{ $title }} + + + + + + + + + +
+ SiteBoss +
+
+

{{ $title }}

+ {{ $slot }} +
+ + + + diff --git a/resources/views/pages/block-account.blade.php b/resources/views/pages/block-account.blade.php new file mode 100644 index 00000000..86a74df5 --- /dev/null +++ b/resources/views/pages/block-account.blade.php @@ -0,0 +1,7 @@ + +

+ {{ $message }} +

+ + +
diff --git a/src/Http/Controllers/Auth/VerifyEmailController.php b/src/Http/Controllers/Auth/VerifyEmailController.php index fc3dfd05..3b524c46 100644 --- a/src/Http/Controllers/Auth/VerifyEmailController.php +++ b/src/Http/Controllers/Auth/VerifyEmailController.php @@ -33,12 +33,13 @@ public function __invoke(Request $request) 'hash' => $request->route('hash'), ]); - return [ + return view('siteboss::pages.block-account',[ 'result' => 'error', - 'message' => __('siteboss::auth.verify_block_account'), - 'buttonText' => __('siteboss::auth.block_account_button'), + 'title' => __('siteboss::auth.verify_block_account_title'), + 'message' => __('siteboss::auth.verify_block_account_message'), + 'buttonText' => __('siteboss::auth.verify_block_account_button'), 'link' => $link, - ]; + ]); } if (! $user) { @@ -72,7 +73,7 @@ public function block(Request $request) $user->email_verified_at = null; $user->save(); - Mail::to(env('SB_ADMIN_EMAIL'))->send(new AccountBlocked($user)); + Mail::to(config('siteboss.admin_email'))->send(new AccountBlocked($user)); return ['status' => 'ok', 'message' => __('siteboss::auth.block_account_message')]; } From b133b72078d0a1114943de710df9056f868aebe0 Mon Sep 17 00:00:00 2001 From: Rene Date: Fri, 9 Feb 2024 12:50:34 +0100 Subject: [PATCH 10/13] feat: templates --- lang/nl/auth.php | 6 +++--- resources/views/pages/block-account.blade.php | 5 ++++- resources/views/pages/block-success.blade.php | 5 +++++ src/Http/Controllers/Auth/VerifyEmailController.php | 8 ++++++-- src/Services/Assets/AbstractAssetService.php | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 resources/views/pages/block-success.blade.php diff --git a/lang/nl/auth.php b/lang/nl/auth.php index 3942e6eb..13c64bad 100644 --- a/lang/nl/auth.php +++ b/lang/nl/auth.php @@ -24,10 +24,10 @@ 'verify_email_success' => 'Account successvol geverifieerd.', 'verify_wrong_email' => 'Heb je zelf niet geprobeerd in te loggen? Klik dan hier om deze poging te blokkeren.', - + 'verify_block_account_title' => 'Account blokkeren?', 'verify_block_account_message' => 'Wil je voor de zekerheid jouw account blokkeren? Je kunt dan niet meer inloggen op SiteBoss. Een administrator kan jouw account weer deblokkeren.', 'verify_block_account_button' => 'Blokkeer account', - - 'block_account_message' => 'Account succesvol geblokkeerd.', + 'block_account_title' => 'Account geblokkeerd', + 'block_account_message' => 'Vraag een beheerder om je account te herstellen.', ]; diff --git a/resources/views/pages/block-account.blade.php b/resources/views/pages/block-account.blade.php index 86a74df5..dbda49cd 100644 --- a/resources/views/pages/block-account.blade.php +++ b/resources/views/pages/block-account.blade.php @@ -3,5 +3,8 @@ {{ $message }}

- + {{ $buttonText }} diff --git a/resources/views/pages/block-success.blade.php b/resources/views/pages/block-success.blade.php new file mode 100644 index 00000000..cc850ecf --- /dev/null +++ b/resources/views/pages/block-success.blade.php @@ -0,0 +1,5 @@ + +

+ {{ $message }} +

+
diff --git a/src/Http/Controllers/Auth/VerifyEmailController.php b/src/Http/Controllers/Auth/VerifyEmailController.php index 3b524c46..8217abd8 100644 --- a/src/Http/Controllers/Auth/VerifyEmailController.php +++ b/src/Http/Controllers/Auth/VerifyEmailController.php @@ -33,7 +33,7 @@ public function __invoke(Request $request) 'hash' => $request->route('hash'), ]); - return view('siteboss::pages.block-account',[ + return view('siteboss::pages.block-account', [ 'result' => 'error', 'title' => __('siteboss::auth.verify_block_account_title'), 'message' => __('siteboss::auth.verify_block_account_message'), @@ -75,6 +75,10 @@ public function block(Request $request) Mail::to(config('siteboss.admin_email'))->send(new AccountBlocked($user)); - return ['status' => 'ok', 'message' => __('siteboss::auth.block_account_message')]; + return view('siteboss::pages.block-success', + [ + 'title' => __('siteboss::auth.block_account_title'), + 'message' => __('siteboss::auth.block_account_message'), + ]); } } diff --git a/src/Services/Assets/AbstractAssetService.php b/src/Services/Assets/AbstractAssetService.php index f343b4eb..76b9f609 100644 --- a/src/Services/Assets/AbstractAssetService.php +++ b/src/Services/Assets/AbstractAssetService.php @@ -57,7 +57,7 @@ public function getLang(): Lang /** * Loops through all the table items and return them with the appropriate Input Class */ - public function getFieldComponents(?int $recordId = null): Collection + public function getFieldComponents(int $recordId = null): Collection { $items = $this->assetModel->items()->where('enabled', 1)->orderBy('order')->get(); From b8904ef6290c887cc505786098a90a2899d3705d Mon Sep 17 00:00:00 2001 From: Rene Date: Fri, 9 Feb 2024 13:53:06 +0100 Subject: [PATCH 11/13] fix: english language --- lang/en/auth.php | 1 + routes/api.php | 15 +++++++++++---- src/Auth/Notifications/VerifyEmail.php | 1 + .../Controllers/Auth/VerifyEmailController.php | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lang/en/auth.php b/lang/en/auth.php index ca942e70..e0d56ad1 100644 --- a/lang/en/auth.php +++ b/lang/en/auth.php @@ -24,6 +24,7 @@ 'verify_email_link_sent' => 'A fresh verification link has been sent to your email address.', 'verify_email_success' => 'Account successfully verified.', 'verify_wrong_email' => 'Click here to block this attempt if you were not the one who tried to login.', + 'block_account_title' => 'Account blocked', 'block_account_message' => 'The account has been blocked.', 'verify_block_account_title' => 'Block account?', 'verify_block_account_message' => 'Are you sure you want to block this account? You will not be able to login to SiteBoss. An administrator can unblock your account.', diff --git a/routes/api.php b/routes/api.php index 0d00a9a7..3378b050 100644 --- a/routes/api.php +++ b/routes/api.php @@ -28,14 +28,21 @@ | */ Route::prefix(config('siteboss.api_prefix'))->group(function () { - Route::prefix('api')->group(function () { + + // Routes account management + Route::group(['prefix' => '/{locale}', 'middleware' => [ ValidateSignature::class,'throttle:6,1', 'set-forget-locale']], function () { + + // Verify email address Route::get('email/verify/{id}/{hash}', [VerifyEmailController::class, '__invoke']) - ->middleware([ValidateSignature::class, 'throttle:6,1']) ->name('siteboss.verification.verify'); - + + // Routes for blocking your own account Route::get('email/verify/block/{id}/{hash}', [VerifyEmailController::class, 'block']) - ->middleware([ValidateSignature::class, 'throttle:6,1']) ->name('siteboss.verification.block'); + }); + + + Route::prefix('api')->group(function () { // Unauthenticated routes Route::namespace('Forms')->group(function () { diff --git a/src/Auth/Notifications/VerifyEmail.php b/src/Auth/Notifications/VerifyEmail.php index b41ac5cf..f94c967a 100644 --- a/src/Auth/Notifications/VerifyEmail.php +++ b/src/Auth/Notifications/VerifyEmail.php @@ -85,6 +85,7 @@ protected function verificationUrl($notifiable) Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), [ 'id' => $notifiable->getKey(), + 'locale'=> app()->getLocale(), 'hash' => sha1($notifiable->getEmailForVerification()), ] ); diff --git a/src/Http/Controllers/Auth/VerifyEmailController.php b/src/Http/Controllers/Auth/VerifyEmailController.php index 8217abd8..ad85feab 100644 --- a/src/Http/Controllers/Auth/VerifyEmailController.php +++ b/src/Http/Controllers/Auth/VerifyEmailController.php @@ -29,6 +29,7 @@ public function __invoke(Request $request) 'siteboss.verification.block', Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), [ + 'locale' => app()->getLocale(), 'id' => $request->route('id'), 'hash' => $request->route('hash'), ]); From e3d6168bb22dcb1113f99ecbf631bf1aaeafc647 Mon Sep 17 00:00:00 2001 From: Rene Date: Fri, 9 Feb 2024 13:58:36 +0100 Subject: [PATCH 12/13] feat: template for succes --- lang/nl/auth.php | 2 +- ...ck-account.blade.php => messaage-button.blade.php} | 0 .../{block-success.blade.php => message.blade.php} | 0 src/Http/Controllers/Auth/VerifyEmailController.php | 11 ++++++++--- 4 files changed, 9 insertions(+), 4 deletions(-) rename resources/views/pages/{block-account.blade.php => messaage-button.blade.php} (100%) rename resources/views/pages/{block-success.blade.php => message.blade.php} (100%) diff --git a/lang/nl/auth.php b/lang/nl/auth.php index 13c64bad..72f04238 100644 --- a/lang/nl/auth.php +++ b/lang/nl/auth.php @@ -21,7 +21,7 @@ 'verify_email_link' => 'Klik op onderstaande link om je e-mailadres te bevestigen.', 'verify_email_resend' => 'Verificatiemail opnieuw verzenden', 'verify_email_link_sent' => 'Er is een nieuwe verificatielink naar jouw e-mailadres verzonden.', - 'verify_email_success' => 'Account successvol geverifieerd.', + 'verify_email_success' => 'Account succesvol geverifieerd.', 'verify_wrong_email' => 'Heb je zelf niet geprobeerd in te loggen? Klik dan hier om deze poging te blokkeren.', diff --git a/resources/views/pages/block-account.blade.php b/resources/views/pages/messaage-button.blade.php similarity index 100% rename from resources/views/pages/block-account.blade.php rename to resources/views/pages/messaage-button.blade.php diff --git a/resources/views/pages/block-success.blade.php b/resources/views/pages/message.blade.php similarity index 100% rename from resources/views/pages/block-success.blade.php rename to resources/views/pages/message.blade.php diff --git a/src/Http/Controllers/Auth/VerifyEmailController.php b/src/Http/Controllers/Auth/VerifyEmailController.php index ad85feab..7bbf6720 100644 --- a/src/Http/Controllers/Auth/VerifyEmailController.php +++ b/src/Http/Controllers/Auth/VerifyEmailController.php @@ -34,7 +34,7 @@ public function __invoke(Request $request) 'hash' => $request->route('hash'), ]); - return view('siteboss::pages.block-account', [ + return view('siteboss::pages.message-button', [ 'result' => 'error', 'title' => __('siteboss::auth.verify_block_account_title'), 'message' => __('siteboss::auth.verify_block_account_message'), @@ -55,7 +55,12 @@ public function __invoke(Request $request) event(new Verified($user)); } - return ['status' => 'ok', 'message' => __('siteboss::auth.verify_email_success')]; + return view('siteboss::pages.message', + [ + 'title' => __('siteboss::auth.verify_email_success'), + 'message' => __('siteboss::auth.verify_email_success') + ] + ); } public function block(Request $request) @@ -76,7 +81,7 @@ public function block(Request $request) Mail::to(config('siteboss.admin_email'))->send(new AccountBlocked($user)); - return view('siteboss::pages.block-success', + return view('siteboss::pages.message', [ 'title' => __('siteboss::auth.block_account_title'), 'message' => __('siteboss::auth.block_account_message'), From d4d4f98c74872b9fc96454f46c9c97d555a4de43 Mon Sep 17 00:00:00 2001 From: Rene Date: Fri, 9 Feb 2024 13:59:17 +0100 Subject: [PATCH 13/13] style: formatting --- routes/api.php | 11 +++++------ src/Auth/Notifications/VerifyEmail.php | 2 +- src/Http/Controllers/Auth/VerifyEmailController.php | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/routes/api.php b/routes/api.php index 3378b050..d3728b51 100644 --- a/routes/api.php +++ b/routes/api.php @@ -28,20 +28,19 @@ | */ Route::prefix(config('siteboss.api_prefix'))->group(function () { - + // Routes account management - Route::group(['prefix' => '/{locale}', 'middleware' => [ ValidateSignature::class,'throttle:6,1', 'set-forget-locale']], function () { - + Route::group(['prefix' => '/{locale}', 'middleware' => [ValidateSignature::class, 'throttle:6,1', 'set-forget-locale']], function () { + // Verify email address Route::get('email/verify/{id}/{hash}', [VerifyEmailController::class, '__invoke']) ->name('siteboss.verification.verify'); - + // Routes for blocking your own account Route::get('email/verify/block/{id}/{hash}', [VerifyEmailController::class, 'block']) ->name('siteboss.verification.block'); }); - - + Route::prefix('api')->group(function () { // Unauthenticated routes diff --git a/src/Auth/Notifications/VerifyEmail.php b/src/Auth/Notifications/VerifyEmail.php index f94c967a..902bba00 100644 --- a/src/Auth/Notifications/VerifyEmail.php +++ b/src/Auth/Notifications/VerifyEmail.php @@ -85,7 +85,7 @@ protected function verificationUrl($notifiable) Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), [ 'id' => $notifiable->getKey(), - 'locale'=> app()->getLocale(), + 'locale' => app()->getLocale(), 'hash' => sha1($notifiable->getEmailForVerification()), ] ); diff --git a/src/Http/Controllers/Auth/VerifyEmailController.php b/src/Http/Controllers/Auth/VerifyEmailController.php index 7bbf6720..7cffb5c3 100644 --- a/src/Http/Controllers/Auth/VerifyEmailController.php +++ b/src/Http/Controllers/Auth/VerifyEmailController.php @@ -56,11 +56,11 @@ public function __invoke(Request $request) } return view('siteboss::pages.message', - [ - 'title' => __('siteboss::auth.verify_email_success'), - 'message' => __('siteboss::auth.verify_email_success') + [ + 'title' => __('siteboss::auth.verify_email_success'), + 'message' => __('siteboss::auth.verify_email_success'), ] - ); + ); } public function block(Request $request)