mirror of
https://github.com/Chewbaccalakis/rfid-database.git
synced 2026-09-10 00:11:56 -07:00
Auth.js OIDC only reads ID-token claims by default; Authelia puts email on UserInfo. Set idToken:false, harden claim extraction, and document an optional Authelia claims_policy.
25 lines
769 B
TypeScript
25 lines
769 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { emailFromOidcProfile } from "@/lib/auth/oidc";
|
|
|
|
describe("emailFromOidcProfile", () => {
|
|
it("reads email claim", () => {
|
|
expect(emailFromOidcProfile({ email: "[email protected]" })).toBe(
|
|
"[email protected]"
|
|
);
|
|
});
|
|
|
|
it("falls back to preferred_username when it looks like an email", () => {
|
|
expect(
|
|
emailFromOidcProfile({ preferred_username: "[email protected]" })
|
|
).toBe("[email protected]");
|
|
});
|
|
|
|
it("ignores non-email preferred_username", () => {
|
|
expect(emailFromOidcProfile({ preferred_username: "nick" })).toBeNull();
|
|
});
|
|
|
|
it("returns null when nothing usable is present", () => {
|
|
expect(emailFromOidcProfile({ sub: "abc", name: "Nick" })).toBeNull();
|
|
});
|
|
});
|