Skip to content

Commit 859c4c3

Browse files
committed
refactor: added demo logins to login page
1 parent a8fe7b2 commit 859c4c3

File tree

6 files changed

+62
-19
lines changed

6 files changed

+62
-19
lines changed

TODO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- [x] Homepage
33
- [x] Footer
44
- [x] About us page
5-
- [ ] Contact us page
5+
- [x] Contact us page
66
- [x] Login
77
- [x] Register
88
- [ ] Forgot Password
@@ -11,7 +11,7 @@
1111
- [x] Admin - dashboard
1212
- [x] Admin - configurations
1313
- [x] Admin - reset system
14-
- [ ] Admin Contact us messages
14+
- [x] Admin Contact us messages
1515
- [ ] Admin - profile
1616
- [x] User - dashboard
1717
- [ ] User - profile
@@ -28,7 +28,7 @@
2828
- [ ] Social logins (Socialite)
2929
- [ ] Admin - dashboard
3030
- [ ] Admin - configurations
31-
- [ ] Admin - manage contact form messages
31+
- [x] Admin - manage contact form messages
3232
- [ ] Admin - reset system
3333
- [ ] Admin - profile
3434
- [ ] User - dashboard

app/Actions/Auth/Pages/Login.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Traits\CustomControllerResponsesTrait;
66
use App\Traits\ThemesTrait;
7+
use Illuminate\Http\Request;
78
use Lorisleiva\Actions\Concerns\AsAction;
89

910
class Login
@@ -12,18 +13,19 @@ class Login
1213
use ThemesTrait;
1314
use CustomControllerResponsesTrait;
1415

15-
public function asController()
16+
public function asController(Request $request)
1617
{
1718
$params = [
1819
'canRegister' => setting('allow_user_registrations'),
1920
'canResetPassword' => setting('allow_user_reset_password'),
2021
'oauth_providers' => config('system.providers') ?? []
2122
];
2223

23-
if(isDemo()) {
24+
if($request->is_demo) {
2425
$params = array_merge([
2526
'username' => config('system.defaults.demo_username'),
2627
'password' => config('system.defaults.demo_password'),
28+
'is_demo' => true
2729
], $params);
2830
}
2931

app/Actions/User/Dashboard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function asController()
1616
return redirect()->route('admin.dashboard');
1717
}
1818

19-
return $this->generateBackendPage('User/Dashboard', [
19+
return $this->generateBackendPage('Dashboard', [
2020
'title' => "Welcome Back, " . doe()->full_name,
2121
]);
2222
}

resources/ts/Layouts/AppLayout.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@
8585
<LightSwitch />
8686
</div>
8787

88-
<span class="">
88+
<span class="mr-2">
8989
<a href={route('contact')} use:inertia class="btn btn-sm variant-ghost-surface">
9090
<i class="bx bx-support text-[20px]" />
9191
Talk to Us
9292
</a>
9393
</span>
9494

95+
<span class="">
96+
<a href={route('demo')} use:inertia class="btn btn-sm variant-ghost-surface"> Demo </a>
97+
</span>
98+
9599
<button
96100
type="button"
97101
class="inline-flex items-center p-2 ml-2 text-sm rounded-lg md:hidden text-primary-token lg:hover:bg-primary-100 focus:outline-none focus:ring-2 focus:ring-primary-300 dark:focus:ring-primary-700"

resources/ts/Pages/Auth/Login.svelte

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
export let canRegister: boolean
1313
export let status: string
1414
export let oauth_providers: string[]
15+
export let username: string | null
16+
export let password: string | null
17+
export let is_demo: boolean = false
18+
19+
let showPassword = false
1520
1621
let form = useForm({
17-
username: '',
18-
password: '',
22+
username: username,
23+
password: password,
1924
remember: false,
2025
})
2126
@@ -32,6 +37,24 @@
3237
<h2 class="text-center">Login</h2>
3338
<p class="text-center">Fill in the form below</p>
3439
<br />
40+
{#if is_demo}
41+
<div class="card p-3">
42+
<h5 class="text-center">Demo Logins</h5>
43+
<div class="flex justify-between">
44+
<div>
45+
<p>Admin</p>
46+
<p>username: <strong>acelords</strong></p>
47+
<p>Password: <strong>acelords</strong></p>
48+
</div>
49+
<div>
50+
<p>User</p>
51+
<p>username: <strong>user</strong></p>
52+
<p>Password: <strong>user</strong></p>
53+
</div>
54+
</div>
55+
</div>
56+
<br />
57+
{/if}
3558
<form on:submit|preventDefault={handleSubmit}>
3659
<label class="label">
3760
<input
@@ -48,13 +71,28 @@
4871
{/if}
4972

5073
<label class="label my-3">
51-
<input
52-
class="input"
53-
class:input-error={$form.errors.username}
54-
type="password"
55-
placeholder="Password"
56-
bind:value={$form.password}
57-
/>
74+
<div class="input-group input-group-divider grid-cols-[1fr_auto]">
75+
{#if showPassword}
76+
<input
77+
class="input"
78+
class:input-error={$form.errors.username}
79+
type="text"
80+
placeholder="Password"
81+
bind:value={$form.password}
82+
/>
83+
{:else}
84+
<input
85+
class="input"
86+
class:input-error={$form.errors.username}
87+
type="password"
88+
placeholder="Password"
89+
bind:value={$form.password}
90+
/>
91+
{/if}
92+
<button type="button" on:click={() => (showPassword = !showPassword)}>
93+
<i class="bx bx-lock" />
94+
</button>
95+
</div>
5896
</label>
5997

6098
<!-- <label class="flex items-center space-x-2 my-3 ml-1">

routes/web.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@
4848
return redirect()->back();
4949
})->name('change-language');
5050

51-
Route::get('/demo', function() {
51+
Route::get('/demo', function () {
5252
return redirect()->to(route('login', [
53-
'username' => config('system.default.demo_username'),
54-
'password' => config('system.default.demo_password'),
53+
'is_demo' => true,
5554
]));
5655
})->name('demo');
5756

0 commit comments

Comments
 (0)