feat: add local signup and Kakao verification gate
This commit is contained in:
@@ -34,6 +34,12 @@ export interface GameSessionTokenPayload {
|
||||
sessionId: string;
|
||||
user: GatewayUserInfo;
|
||||
sanctions: UserSanctions;
|
||||
identity?: {
|
||||
kakaoVerified: boolean;
|
||||
canCreateGeneral: boolean;
|
||||
requiresKakaoVerification: boolean;
|
||||
graceEndsAt: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
const toBase64Url = (data: Buffer): string => data.toString('base64url');
|
||||
@@ -83,6 +89,20 @@ const parsePayload = (value: unknown): GameSessionTokenPayload | null => {
|
||||
if (!payload.sanctions || typeof payload.sanctions !== 'object') {
|
||||
return null;
|
||||
}
|
||||
if (payload.identity !== undefined) {
|
||||
if (!payload.identity || typeof payload.identity !== 'object') {
|
||||
return null;
|
||||
}
|
||||
const identity = payload.identity as Partial<NonNullable<GameSessionTokenPayload['identity']>>;
|
||||
if (
|
||||
typeof identity.kakaoVerified !== 'boolean' ||
|
||||
typeof identity.canCreateGeneral !== 'boolean' ||
|
||||
typeof identity.requiresKakaoVerification !== 'boolean' ||
|
||||
(identity.graceEndsAt !== null && typeof identity.graceEndsAt !== 'string')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return payload as GameSessionTokenPayload;
|
||||
};
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
ALTER TABLE "app_user"
|
||||
ADD COLUMN "terms_accepted_at" TIMESTAMP(3),
|
||||
ADD COLUMN "privacy_accepted_at" TIMESTAMP(3),
|
||||
ADD COLUMN "kakao_verified_at" TIMESTAMP(3),
|
||||
ADD COLUMN "kakao_grace_started_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
|
||||
UPDATE "app_user"
|
||||
SET "kakao_verified_at" = COALESCE("updated_at", "created_at")
|
||||
WHERE "oauth_type" = 'KAKAO'
|
||||
AND "kakao_verified_at" IS NULL;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM "app_user"
|
||||
GROUP BY "display_name"
|
||||
HAVING COUNT(*) > 1
|
||||
) THEN
|
||||
RAISE EXCEPTION
|
||||
'Cannot enforce unique app_user.display_name: resolve duplicate display names before applying this migration.';
|
||||
END IF;
|
||||
END
|
||||
$$;
|
||||
|
||||
CREATE UNIQUE INDEX "app_user_display_name_key" ON "app_user"("display_name");
|
||||
@@ -53,7 +53,7 @@ enum GatewaySourceMode {
|
||||
model AppUser {
|
||||
id String @id @default(uuid())
|
||||
loginId String @unique @map("login_id")
|
||||
displayName String @map("display_name")
|
||||
displayName String @unique @map("display_name")
|
||||
passwordHash String @map("password_hash")
|
||||
passwordSalt String @map("password_salt")
|
||||
roles Json @default(dbgenerated("'[]'::jsonb"))
|
||||
@@ -66,6 +66,10 @@ model AppUser {
|
||||
imageServer Int @default(0) @map("image_server")
|
||||
iconUpdatedAt DateTime? @map("icon_updated_at")
|
||||
thirdPartyUse Boolean @default(true) @map("third_party_use")
|
||||
termsAcceptedAt DateTime? @map("terms_accepted_at")
|
||||
privacyAcceptedAt DateTime? @map("privacy_accepted_at")
|
||||
kakaoVerifiedAt DateTime? @map("kakao_verified_at")
|
||||
kakaoGraceStartedAt DateTime @default(now()) @map("kakao_grace_started_at")
|
||||
deleteAfter DateTime? @map("delete_after")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
Reference in New Issue
Block a user