test: cover share authentication and copy behavior
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { ShareHttpError } from "@/lib/share/http-error";
|
||||
|
||||
export type ShareSession = {
|
||||
user?: {
|
||||
id?: string | null;
|
||||
discordId?: string | null;
|
||||
} | null;
|
||||
} | null;
|
||||
|
||||
export function requireShareSessionIdentity(session: ShareSession) {
|
||||
const userId = session?.user?.id;
|
||||
const discordId = session?.user?.discordId;
|
||||
if (!userId || !discordId) {
|
||||
throw new ShareHttpError("Unauthorized", 401);
|
||||
}
|
||||
return { userId, discordId };
|
||||
}
|
||||
Reference in New Issue
Block a user