create-feltkit 0.3.13 → 0.3.15
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/package.json
CHANGED
package/template/_gitignore
CHANGED
|
@@ -2,4 +2,11 @@ node_modules/
|
|
|
2
2
|
dist/
|
|
3
3
|
.feltkit/
|
|
4
4
|
.feltkit-platform/
|
|
5
|
+
# Credentials and local deployment state: environment files (FELTKIT_*, FELTDB_* keys), and what
|
|
6
|
+
# `feltdb init-managed` / `feltdb managed keys` write if this app later moves to Managed FeltDB.
|
|
7
|
+
# Never commit.
|
|
8
|
+
.env
|
|
9
|
+
.env.*
|
|
10
|
+
!.env.example
|
|
11
|
+
.feltdb/
|
|
5
12
|
*.app/
|
package/template/package.json
CHANGED
package/template/src/App.tsx
CHANGED
|
@@ -161,16 +161,55 @@ function SignedOut(props: {
|
|
|
161
161
|
) : props.accounts ? (
|
|
162
162
|
<AccountForm signUpOpen={props.accounts.signUp} email={Boolean(props.accounts.email)} providers={props.accounts.providers ?? []} onSignIn={props.onSignIn} onSignUp={props.onSignUp} />
|
|
163
163
|
) : (
|
|
164
|
-
|
|
165
|
-
<h1>Sign in</h1>
|
|
166
|
-
<p className="muted">Sign-in isn't available for this app yet.</p>
|
|
167
|
-
</>
|
|
164
|
+
<SessionForm />
|
|
168
165
|
)}
|
|
169
166
|
</div>
|
|
170
167
|
</div>
|
|
171
168
|
);
|
|
172
169
|
}
|
|
173
170
|
|
|
171
|
+
/**
|
|
172
|
+
* No dev users and no accounts: access is given by whoever operates the deployment (on AppBoundry,
|
|
173
|
+
* `appboundry admin sessions issue --user <id>`). The session they hand over is pasted here; the
|
|
174
|
+
* server decides whether it is valid, and what it may do.
|
|
175
|
+
*/
|
|
176
|
+
function SessionForm() {
|
|
177
|
+
const client = useFeltKit();
|
|
178
|
+
const [token, setToken] = useState("");
|
|
179
|
+
const [error, setError] = useState<string | null>(null);
|
|
180
|
+
const [busy, setBusy] = useState(false);
|
|
181
|
+
const submit = async (e: FormEvent) => {
|
|
182
|
+
e.preventDefault();
|
|
183
|
+
setError(null);
|
|
184
|
+
setBusy(true);
|
|
185
|
+
try {
|
|
186
|
+
client.setToken(token.trim());
|
|
187
|
+
const session = await client.session();
|
|
188
|
+
if (!session.principal) {
|
|
189
|
+
client.setToken(null);
|
|
190
|
+
setError("That session isn't valid, or it has expired or been revoked. Ask your operator for a new one.");
|
|
191
|
+
}
|
|
192
|
+
} catch (err) {
|
|
193
|
+
client.setToken(null);
|
|
194
|
+
setError(describe(err));
|
|
195
|
+
} finally {
|
|
196
|
+
setBusy(false);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
return (
|
|
200
|
+
<form className="stack" onSubmit={submit}>
|
|
201
|
+
<h1>Sign in</h1>
|
|
202
|
+
<p className="muted">Access to this app is given by its operator. Paste the session they issued you.</p>
|
|
203
|
+
<label className="field">
|
|
204
|
+
<span>Session</span>
|
|
205
|
+
<input type="password" autoComplete="off" spellCheck={false} value={token} onChange={(e) => setToken(e.target.value)} placeholder="abs_…" required autoFocus />
|
|
206
|
+
</label>
|
|
207
|
+
{error && <p className="error-text" role="alert">{error}</p>}
|
|
208
|
+
<button className="wide" type="submit" disabled={busy || !token.trim()}>{busy ? "Signing in…" : "Sign in"}</button>
|
|
209
|
+
</form>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
174
213
|
/** Sign in to an existing account, or create one (auth.accounts in feltkit/app.ts). */
|
|
175
214
|
function AccountForm(props: {
|
|
176
215
|
signUpOpen: boolean;
|