fix(GRO-1272): auto-provision staff record on first OIDC login #19
@@ -65,13 +65,17 @@ vi.mock("../db", () => {
|
|||||||
|
|
|||||||
const user = makeTableProxy("user");
|
const user = makeTableProxy("user");
|
||||||
|
|
||||||
const buildQuery = (result: unknown, fallback: unknown) => ({
|
const buildQuery = (result: unknown, fallback: unknown) => ({
|
||||||
limit: () => ({
|
[Symbol.iterator]: function* () {
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
[Symbol.iterator]: function* () {
|
if (result) yield result;
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
if (result) yield result;
|
},
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
},
|
limit: (_n: number) => {
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
0: result,
|
const item = result ?? fallback;
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
length: result ? 1 : 0,
|
return {
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
}),
|
[Symbol.iterator]: function* () { if (item) yield item; },
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
|
0: item,
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
|
length: item ? 1 : 0,
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
|
};
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
|
},
|
||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
|
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
Lint Roller
commented
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null. returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
|
|||||||
@@ -130,6 +130,9 @@ export const resolveStaffMiddleware: MiddlewareHandler<AppEnv> = async (
|
|||||||
|
Lint Roller
commented
TS2769: is — add a guard before to avoid passing . TS2769: is — add a guard before to avoid passing .
Lint Roller
commented
TS2769: is — add a guard before to avoid passing . TS2769: is — add a guard before to avoid passing .
|
|||||||
active: true,
|
active: true,
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
|
if (!newStaff) {
|
||||||
|
Lint Roller
commented
TS2769: is — add a guard before to avoid passing . TS2769: is — add a guard before to avoid passing .
|
|||||||
|
return c.json({ error: "Internal error: staff record creation failed" }, 500);
|
||||||
|
Lint Roller
commented
TS2769: is — add a guard before to avoid passing . TS2769: is — add a guard before to avoid passing .
|
|||||||
|
}
|
||||||
|
Lint Roller
commented
TS2769: is — add a guard before to avoid passing . TS2769: is — add a guard before to avoid passing .
|
|||||||
c.set("staff", newStaff);
|
c.set("staff", newStaff);
|
||||||
await next();
|
await next();
|
||||||
return;
|
return;
|
||||||
|
|||||||
|
Lint Roller
commented
TS2769: is — add a guard before to avoid passing . TS2769: is — add a guard before to avoid passing .
Lint Roller
commented
TS2769: is — add a guard before to avoid passing . TS2769: is — add a guard before to avoid passing .
|
|||||||
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.
returns with no . All non-limit WHERE queries throw TypeError → 500. Add to the returned object, and make fall back to when is null.