fixed auth strategy toggle, updated astro/remix

This commit is contained in:
dswbx
2025-01-17 18:08:23 +01:00
parent baab70f9da
commit 7ddcfc89b4
9 changed files with 42 additions and 28 deletions

View File

@@ -128,15 +128,17 @@ export class Api {
};
}
async getVerifiedAuthState(force?: boolean): Promise<AuthState> {
if (force === true || !this.verified) {
await this.verifyAuth();
}
async getVerifiedAuthState(): Promise<AuthState> {
await this.verifyAuth();
return this.getAuthState();
}
async verifyAuth() {
if (!this.token) {
this.markAuthVerified(false);
return;
}
try {
const res = await this.auth.me();
if (!res.ok || !res.body.user) {

View File

@@ -226,8 +226,16 @@ export class AppAuth extends Module<typeof authConfigSchema> {
private toggleStrategyValueVisibility(visible: boolean) {
const field = this.getUsersEntity().field("strategy_value")!;
field.config.hidden = !visible;
field.config.fillable = visible;
if (visible) {
field.config.hidden = false;
field.config.fillable = true;
} else {
// reset to normal
const template = AppAuth.usersFields.strategy_value.config;
field.config.hidden = template.hidden;
field.config.fillable = template.fillable;
}
// @todo: think about a PasswordField that automatically hashes on save?
}

View File

@@ -33,7 +33,6 @@ export class AuthController extends Controller {
const name = strategy.getName();
const { create, change } = actions;
const em = this.auth.em;
const mutator = em.mutator(this.auth.config.entity_name as "users");
if (create) {
hono.post(
@@ -46,10 +45,9 @@ export class AuthController extends Controller {
skipMark: true
});
const processed = (await create.preprocess?.(valid)) ?? valid;
console.log("processed", processed);
// @todo: check processed for "role" and check permissions
const mutator = em.mutator(this.auth.config.entity_name as "users");
mutator.__unstable_toggleSystemEntityCreation(false);
const { data: created } = await mutator.insertOne({
...processed,
@@ -98,7 +96,7 @@ export class AuthController extends Controller {
hono.get("/me", auth(), async (c) => {
if (this.auth.authenticator.isUserLoggedIn()) {
return c.json({ user: await this.auth.authenticator.getUser() });
return c.json({ user: this.auth.authenticator.getUser() });
}
return c.json({ user: null }, 403);

View File

@@ -1,3 +1,4 @@
@import "./main.css";
@import "./components/form/json-schema/styles.css";
@import "@xyflow/react/dist/style.css";
@import "@mantine/core/styles.css";