Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Emails (reset, verification, magic links, alerts) need a working mail setup.
## Demo data

```bash
php artisan modules:seed --module=auth --demo
php artisan modules:seed --module=auth --state=showcase
```

Adds a user (`chef@saucebase.dev`) and a support staff account (`support@saucebase.dev`) that only sees user admin. Both use the `DEMO_PASSWORD` from `.env`.
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ tasks:

# ── Database ──────────────────────────────────────────────────

db:seed:demo:
db:seed:showcase:
desc: Seed the Auth module with sample content
cmd: '{{.APP}} php artisan modules:seed --module=auth --demo'
cmd: '{{.APP}} php artisan modules:seed --module=auth --state=showcase'

make-admin:
desc: Promote an user to Admin
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"Modules\\Auth\\Providers\\AuthServiceProvider"
],
"aliases": {}
},
"branch-alias": {
"dev-dev": "3.9.x-dev"
}
},
"autoload": {
Expand All @@ -37,7 +40,7 @@
}
},
"require": {
"saucebase/core": "^2.8.1",
"saucebase/core": "^3.0",
"laravel/socialite": "^5.31",
"stechstudio/filament-impersonate": "^5.6.1",
"laravel/passkeys": "^0.2.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;

class DemoAuthDatabaseSeeder extends Seeder
class ShowcaseAuthDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
Expand Down
10 changes: 8 additions & 2 deletions resources/js/react/pages/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AlertMessage from '@/components/AlertMessage';
import { Modal } from '@inertiaui/modal-react';
import { useSettings } from '@saucebase/react/hooks/useSettings';
import { useT } from '@saucebase/react/i18n';
import LoginForm from '../components/LoginForm';
import AuthCardLayout from '../layouts/AuthCardLayout';
Expand All @@ -20,12 +21,15 @@ interface LoginProps {
*/
export default function Login({ status, error, modal }: LoginProps) {
const t = useT();
const settings = useSettings();

if (!modal) {
return (
<AuthCardLayout
title={t('Welcome back')}
description={t('Login to your Saucebase account to continue')}
description={t('Login to your :app account to continue', {
app: settings.general.site_name,
})}
>
<LoginForm />
</AuthCardLayout>
Expand All @@ -40,7 +44,9 @@ export default function Login({ status, error, modal }: LoginProps) {
{t('Welcome back')}
</h2>
<p className="text-muted-foreground text-sm">
{t('Login to your Saucebase account to continue')}
{t('Login to your :app account to continue', {
app: settings.general.site_name,
})}
</p>
</div>

Expand Down
12 changes: 8 additions & 4 deletions resources/js/react/pages/Register.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Modal } from '@inertiaui/modal-react';
import { useSettings } from '@saucebase/react/hooks/useSettings';
import { useT } from '@saucebase/react/i18n';
import RegisterForm from '../components/RegisterForm';
import AuthCardLayout from '../layouts/AuthCardLayout';
Expand All @@ -10,14 +11,15 @@ interface RegisterProps {
/** Registration, as a page or a modal. See `Login.tsx` for the reasoning. */
export default function Register({ modal }: RegisterProps) {
const t = useT();
const settings = useSettings();

if (!modal) {
return (
<AuthCardLayout
title={t('Create your account')}
description={t(
'Sign up for Saucebase to start building your SaaS',
)}
description={t('Sign up for :app to get started', {
app: settings.general.site_name,
})}
>
<RegisterForm />
</AuthCardLayout>
Expand All @@ -32,7 +34,9 @@ export default function Register({ modal }: RegisterProps) {
{t('Create your account')}
</h2>
<p className="text-muted-foreground text-sm">
{t('Sign up for Saucebase to start building your SaaS')}
{t('Sign up for :app to get started', {
app: settings.general.site_name,
})}
</p>
</div>

Expand Down
15 changes: 13 additions & 2 deletions resources/js/vue/pages/Login.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<script setup lang="ts">
import { useSettings } from '@saucebase/vue/composables/useSettings';
import AlertMessage from '@/components/AlertMessage.vue';
import { Modal } from '@inertiaui/modal-vue';
import LoginForm from '../components/LoginForm.vue';
import AuthCardLayout from '../layouts/AuthCardLayout.vue';

const settings = useSettings();

/**
* Signing in, as a page or as a modal over whatever the visitor was reading.
*
Expand All @@ -25,7 +28,11 @@ defineProps<{
<div class="space-y-1.5 text-center">
<h2 class="text-2xl font-semibold">{{ $t('Welcome back') }}</h2>
<p class="text-muted-foreground text-sm">
{{ $t('Login to your Saucebase account to continue') }}
{{
$t('Login to your :app account to continue', {
app: settings.general.site_name,
})
}}
</p>
</div>

Expand All @@ -44,7 +51,11 @@ defineProps<{
<AuthCardLayout
v-else
:title="$t('Welcome back')"
:description="$t('Login to your Saucebase account to continue')"
:description="
$t('Login to your :app account to continue', {
app: settings.general.site_name,
})
"
>
<LoginForm />
</AuthCardLayout>
Expand Down
13 changes: 11 additions & 2 deletions resources/js/vue/pages/Register.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<script setup lang="ts">
import { useSettings } from '@saucebase/vue/composables/useSettings';
import { Modal } from '@inertiaui/modal-vue';
import RegisterForm from '../components/RegisterForm.vue';
import AuthCardLayout from '../layouts/AuthCardLayout.vue';

const settings = useSettings();

/** Registration, as a page or a modal. See `Login.vue` for the reasoning. */
defineProps<{
modal?: boolean;
Expand All @@ -18,7 +21,9 @@ defineProps<{
</h2>
<p class="text-muted-foreground text-sm">
{{
$t('Sign up for Saucebase to start building your SaaS')
$t('Sign up for :app to get started', {
app: settings.general.site_name,
})
}}
</p>
</div>
Expand All @@ -30,7 +35,11 @@ defineProps<{
<AuthCardLayout
v-else
:title="$t('Create your account')"
:description="$t('Sign up for Saucebase to start building your SaaS')"
:description="
$t('Sign up for :app to get started', {
app: settings.general.site_name,
})
"
>
<RegisterForm />
</AuthCardLayout>
Expand Down
5 changes: 5 additions & 0 deletions src/Settings/AuthSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@

namespace Modules\Auth\Settings;

use Saucebase\Core\Settings\InstallSetting;
use Spatie\LaravelSettings\Settings;

class AuthSettings extends Settings
{
/** @var list<string> */
public array $enabled_socialite_providers;

#[InstallSetting('Let people sign up?', hint: 'Off: only invited or admin-created accounts.')]
public bool $registration_enabled;

/** Whether signing in and registering open in a modal over the current page. */
#[InstallSetting('Open sign-in and sign-up in a modal?')]
public bool $modal_enabled;

#[InstallSetting('Let people sign in with an emailed link?')]
public bool $magic_link_enabled;

public int $magic_link_expiry;

public bool $login_notification_enabled;

/** Whether users can register passkeys and sign in with them. */
#[InstallSetting('Let people sign in with passkeys?')]
public bool $passkeys_enabled;

public static function group(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Modules\Auth\Database\Seeders\DatabaseSeeder;
use Modules\Auth\Database\Seeders\DemoAuthDatabaseSeeder;
use Modules\Auth\Database\Seeders\ShowcaseAuthDatabaseSeeder;
use Tests\TestCase;

/**
* The demo ships a staff account for this module's admin area, so visitors can try a
* role that sees only part of the panel.
*/
class DemoStaffTest extends TestCase
class ShowcaseStaffTest extends TestCase
{
use RefreshDatabase;

public function test_the_demo_adds_a_staff_account_for_this_module_only(): void
{
$this->seed([DatabaseSeeder::class, DemoAuthDatabaseSeeder::class]);
$this->seed([DatabaseSeeder::class, ShowcaseAuthDatabaseSeeder::class]);

$staff = User::where('email', 'support@saucebase.dev')->firstOrFail();

$this->assertSame(['support'], $staff->getRoleNames()->all());
$this->assertEqualsCanonicalizing(['access admin panel', 'manage users', 'impersonate users'], $staff->getAllPermissions()->pluck('name')->all());

Check warning on line 27 in tests/Feature/ShowcaseStaffTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 154 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_auth&issues=AaHgkR9EkRD0nal3vbmN&open=AaHgkR9EkRD0nal3vbmN&pullRequest=68
}

public function test_the_demo_has_one_full_admin_to_sign_in_with(): void
{
$this->seed([DatabaseSeeder::class, DemoAuthDatabaseSeeder::class]);
$this->seed([DatabaseSeeder::class, ShowcaseAuthDatabaseSeeder::class]);

$this->assertSame(['admin'], User::where('email', 'chef@saucebase.dev')->firstOrFail()->getRoleNames()->all());
}
Expand All @@ -38,8 +38,8 @@
{
config(['saucebase.demo_password' => 'not-the-old-default']);

$this->seed([DatabaseSeeder::class, DemoAuthDatabaseSeeder::class]);
$this->seed([DatabaseSeeder::class, ShowcaseAuthDatabaseSeeder::class]);

$this->assertTrue(Hash::check('not-the-old-default', User::where('email', 'support@saucebase.dev')->value('password')));

Check warning on line 43 in tests/Feature/ShowcaseStaffTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 128 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_auth&issues=AaHgkR9EkRD0nal3vbmO&open=AaHgkR9EkRD0nal3vbmO&pullRequest=68
}
}
4 changes: 2 additions & 2 deletions tests/e2e/tests/sidebar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test.describe('Theme persistence', () => {
// Select dark via the UI — this writes localStorage + cookie
await page.getByTestId('user-menu-trigger').click();
await page.getByTestId('theme-selector-trigger').click();
await page.getByRole('menuitem', { name: 'Dark' }).click();
await page.getByTestId('color-mode-dark').click();

await expect(page.locator('html')).toHaveClass(/dark/);

Expand All @@ -73,7 +73,7 @@ test.describe('Theme persistence', () => {
// Select light via the UI
await page.getByTestId('user-menu-trigger').click();
await page.getByTestId('theme-selector-trigger').click();
await page.getByRole('menuitem', { name: 'Light' }).click();
await page.getByTestId('color-mode-light').click();

await expect(page.locator('html')).not.toHaveClass(/dark/);

Expand Down
Loading