@stevederico/skateboard-ui 1.2.12 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/SignInView.jsx +8 -1
- package/SignUpView.jsx +12 -4
- package/Utilities.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/SignInView.jsx
CHANGED
|
@@ -52,7 +52,14 @@ export default function LoginForm({
|
|
|
52
52
|
|
|
53
53
|
if (response.ok) {
|
|
54
54
|
const data = await response.json();
|
|
55
|
-
// CSRF token
|
|
55
|
+
// Save CSRF token from cookie to localStorage for isAuthenticated() check
|
|
56
|
+
const csrfCookie = document.cookie.split('; ').find(row => row.startsWith('csrf_token='));
|
|
57
|
+
if (csrfCookie) {
|
|
58
|
+
const csrfToken = csrfCookie.split('=')[1];
|
|
59
|
+
const appName = constants.appName || 'skateboard';
|
|
60
|
+
const csrfKey = `${appName.toLowerCase().replace(/\s+/g, '-')}_csrf`;
|
|
61
|
+
localStorage.setItem(csrfKey, csrfToken);
|
|
62
|
+
}
|
|
56
63
|
dispatch({ type: 'SET_USER', payload: data });
|
|
57
64
|
navigate('/app');
|
|
58
65
|
} else {
|
package/SignUpView.jsx
CHANGED
|
@@ -34,7 +34,8 @@ export default function LoginForm({
|
|
|
34
34
|
}
|
|
35
35
|
}, [])
|
|
36
36
|
|
|
37
|
-
async function signUpClicked() {
|
|
37
|
+
async function signUpClicked(e) {
|
|
38
|
+
e.preventDefault();
|
|
38
39
|
// Client-side password validation (matches backend: 6-72 chars)
|
|
39
40
|
if (password.length < 6) {
|
|
40
41
|
setErrorMessage('Password must be at least 6 characters');
|
|
@@ -54,7 +55,14 @@ export default function LoginForm({
|
|
|
54
55
|
|
|
55
56
|
if (response.ok) {
|
|
56
57
|
const data = await response.json();
|
|
57
|
-
// CSRF token
|
|
58
|
+
// Save CSRF token from cookie to localStorage for isAuthenticated() check
|
|
59
|
+
const csrfCookie = document.cookie.split('; ').find(row => row.startsWith('csrf_token='));
|
|
60
|
+
if (csrfCookie) {
|
|
61
|
+
const csrfToken = csrfCookie.split('=')[1];
|
|
62
|
+
const appName = constants.appName || 'skateboard';
|
|
63
|
+
const csrfKey = `${appName.toLowerCase().replace(/\s+/g, '-')}_csrf`;
|
|
64
|
+
localStorage.setItem(csrfKey, csrfToken);
|
|
65
|
+
}
|
|
58
66
|
dispatch({ type: 'SET_USER', payload: data });
|
|
59
67
|
navigate('/app');
|
|
60
68
|
} else {
|
|
@@ -82,7 +90,7 @@ export default function LoginForm({
|
|
|
82
90
|
</div>
|
|
83
91
|
)}
|
|
84
92
|
|
|
85
|
-
<form className="flex flex-col gap-4">
|
|
93
|
+
<form onSubmit={signUpClicked} className="flex flex-col gap-4">
|
|
86
94
|
<Input
|
|
87
95
|
ref={nameInputRef}
|
|
88
96
|
id="name"
|
|
@@ -131,7 +139,7 @@ export default function LoginForm({
|
|
|
131
139
|
</div>
|
|
132
140
|
|
|
133
141
|
<button
|
|
134
|
-
|
|
142
|
+
type="submit"
|
|
135
143
|
className="relative group w-full text-white px-8 py-4 rounded-xl font-semibold text-lg transition-all duration-300 shadow-xl backdrop-blur-sm overflow-hidden cursor-pointer"
|
|
136
144
|
style={{
|
|
137
145
|
backgroundImage: `linear-gradient(to bottom right,
|
package/Utilities.js
CHANGED
|
@@ -118,7 +118,8 @@ export function isAuthenticated() {
|
|
|
118
118
|
return true;
|
|
119
119
|
}
|
|
120
120
|
const csrfKey = getAppKey('csrf');
|
|
121
|
-
|
|
121
|
+
const userKey = getAppKey('user');
|
|
122
|
+
return Boolean(safeGetItem(csrfKey)) && Boolean(safeGetItem(userKey));
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
export function getBackendURL() {
|