-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path+page.svelte
More file actions
134 lines (116 loc) · 3.14 KB
/
Copy path+page.svelte
File metadata and controls
134 lines (116 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<script lang="ts">
import { _ } from 'svelte-i18n';
import SEO from '$lib/components/SEO.svelte';
import ThemeSwitcher from '$lib/components/ThemeSwitcher.svelte';
import YiviLogin from '$lib/components/YiviLogin.svelte';
import logoLight from '$lib/assets/images/logo-wide.svg';
import logoDark from '$lib/assets/images/logo-wide-dark.svg';
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { resolve } from '$app/paths';
import { safeRedirect } from './safe-redirect';
import type { PageData } from './$types';
let { data }: { data: PageData } = $props();
const redirectTo = $derived(page.url.searchParams.get('redirect'));
function handleSuccess() {
// The `redirect` param is attacker-controlled — validate it before navigating.
goto(resolve(safeRedirect(redirectTo) as '/portal/dashboard'));
}
</script>
<SEO title={$_('auth.login')} description={$_('auth.loginSubtitle')} />
<section class="login-page">
<div class="login-header">
<a href={resolve('/')} class="logo">
<img src={logoLight} alt="PostGuard" class="logo-img light-only" height="22" /><img
src={logoDark}
alt="PostGuard"
class="logo-img dark-only"
height="22"
/>
<span class="logo-badge">Business</span>
</a>
<ThemeSwitcher />
</div>
<div class="login-card">
<h1>{$_('auth.login')}</h1>
<p class="login-subtitle">
{$_('auth.loginSubtitle')}
</p>
<div class="login-content">
<p class="login-hint">{$_('auth.loginHint')}</p>
<YiviLogin type="org" attrs={data.yiviAttrs} onSuccess={handleSuccess} />
</div>
<p class="login-footer">
{$_('auth.noAccount')} <a href={resolve('/register')}>{$_('auth.registerOrg')}</a>
</p>
</div>
</section>
<style lang="scss">
.login-page {
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
padding: 0 1.5rem 3rem;
background: var(--pg-general-background);
}
.login-header {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
max-width: 440px;
padding: 1.5rem 0;
}
.logo {
display: flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
}
.logo-badge {
font-family: var(--pg-font-family);
font-size: var(--pg-font-size-xs);
font-weight: var(--pg-font-weight-bold);
background: var(--pg-primary-bg);
color: #fff;
padding: 2px 6px;
border-radius: var(--pg-border-radius-sm);
text-transform: uppercase;
letter-spacing: 0.5px;
}
.login-card {
width: 100%;
max-width: 440px;
background: var(--pg-soft-background);
border: 1px solid var(--pg-strong-background);
border-radius: var(--pg-border-radius-lg);
padding: 2.5rem 2rem;
text-align: center;
h1 {
margin-bottom: 0.5rem;
}
}
.login-subtitle {
color: var(--pg-text-secondary);
margin-bottom: 1.5rem;
}
.login-content {
padding: 1rem 0;
}
.login-hint {
color: var(--pg-text-secondary);
font-size: var(--pg-font-size-sm);
margin-bottom: 1.5rem;
line-height: 1.5;
}
.login-footer {
margin-top: 1.5rem;
font-size: var(--pg-font-size-sm);
color: var(--pg-text-secondary);
a {
color: var(--pg-primary);
font-weight: var(--pg-font-weight-medium);
}
}
</style>