Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client/src/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
// ์„ฌ๊ด‘์ฒ˜๋Ÿผ ๋ณด์ด๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€. logout ์—์„œ์™€ ๋™์ผํ•˜๊ฒŒ ์„ธ์…˜ ์บ์‹œ๋ฅผ ์‹น ๋น„์›€.
clearApiCache();
setUser(res.user);
// ๋กœ๊ทธ์ธ ์‘๋‹ต user ๋Š” /api/me ๋ณด๋‹ค ํ•„๋“œ๊ฐ€ ์ ์„ ์ˆ˜ ์žˆ์–ด(๊ตฌ๋ฒ„์ „ ์„œ๋ฒ„ ๋“ฑ) ํ’€ ๊ฐ์ฒด๋กœ
// ์žฌ๋™๊ธฐํ™” โ€” companyId/isDeveloper ๋ˆ„๋ฝ ์‹œ ์ฝ˜์†” '์„œ๋น„์Šค๋กœ ๋Œ์•„๊ฐ€๊ธฐ'ยท๊ฐœ๋ฐœ์ž ๋ฑƒ์ง€๊ฐ€
// ํ•˜๋“œ ๋ฆฌ๋กœ๋“œ ์ „๊นŒ์ง€ ์‚ฌ๋ผ์ง€๋˜ ๊ฐ„ํ— ๋ฒ„๊ทธ(#1113) ๋ฐฉ์ง€. fire-and-forget.
void refreshRef.current?.();
// ๋กœ๊ทธ์ธ ์งํ›„ ์•Œ๋ฆผ ๊ถŒํ•œ ์š”์ฒญ(iOS/macOS ๋“ฑ ์„ค์น˜ํ˜• ์•ฑ). ๋ผ์šฐํŒ…์„ ๋ง‰์ง€ ์•Š๋„๋ก fire-and-forget.
void requestNotifPermissionOnLogin();
// ์•ˆ๋“œ๋กœ์ด๋“œ: ๋ฐฑ๊ทธ๋ผ์šด๋“œ/์ž ๊ธˆ ์ƒํƒœ ์•Œ๋ฆผ ์‹ ๋ขฐ๋„ ์œ„ํ•ด ๋ฐฐํ„ฐ๋ฆฌ ์ตœ์ ํ™” ์ œ์™ธ 1ํšŒ ์•ˆ๋‚ด(์นดํ†ก ๋ฐฉ์‹).
Expand All @@ -128,6 +132,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
setAuthToken(res.token);
clearApiCache();
setUser(res.user);
// ๋กœ๊ทธ์ธ๊ณผ ๋™์ผ โ€” ํ’€ user ์žฌ๋™๊ธฐํ™”(#1113).
void refreshRef.current?.();
// ๊ฐ€์ž…(=์ตœ์ดˆ ๋กœ๊ทธ์ธ) ์งํ›„์—๋„ ๋™์ผํ•˜๊ฒŒ ์•Œ๋ฆผ ๊ถŒํ•œ ์š”์ฒญ + ๋ฐฐํ„ฐ๋ฆฌ ์ตœ์ ํ™” ์ œ์™ธ ์•ˆ๋‚ด(์•ˆ๋“œ๋กœ์ด๋“œ).
void requestNotifPermissionOnLogin();
void ensureAndroidBatteryExemption();
Expand Down
13 changes: 12 additions & 1 deletion server/src/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ router.post("/login", async (req, res) => {
avatarUrl: user.avatarUrl,
superAdmin: user.superAdmin,
consoleOnly: isConsoleOnlyUser(user),
// /api/me ์™€ ํ•„๋“œ ์ผ์น˜(#1113) โ€” ๋น ์ง€๋ฉด ๋กœ๊ทธ์ธ ์งํ›„ ์„ธ์…˜์ด ํ•˜๋“œ ๋ฆฌ๋กœ๋“œ ์ „๊นŒ์ง€
// companyId ์—†๋Š” ๋ถ€๋ถ„ ๊ฐ์ฒด๋ฅผ ์ฅ์–ด, ์ฝ˜์†” '์„œ๋น„์Šค๋กœ ๋Œ์•„๊ฐ€๊ธฐ'(hasCompany)ยท๊ฐœ๋ฐœ์ž
// ๋ฑƒ์ง€(isDeveloper)๊ฐ€ ๊ฐ„ํ—์ ์œผ๋กœ ์‚ฌ๋ผ์ ธ ๋ณด์ธ๋‹ค.
companyId: user.companyId ?? null,
platformAdmin: user.platformAdmin,
isDeveloper: user.isDeveloper,
},
// ๋„ค์ดํ‹ฐ๋ธŒ ์•ฑ(Capacitor)์€ cross-site ์ฟ ํ‚ค๊ฐ€ ITP ์— ๋ง‰ํ˜€ ์ƒˆ๋กœ๊ณ ์นจ ์‹œ ์„ธ์…˜์ด ๋Š๊ธด๋‹ค.
// ๋„ค์ดํ‹ฐ๋ธŒ origin ์ผ ๋•Œ๋งŒ ์„ธ์…˜ JWT ๋ฅผ ๋ณธ๋ฌธ์œผ๋กœ ํ•จ๊ป˜ ๋‚ด๋ ค, ํด๋ผ๊ฐ€ ์ €์žฅํ•ด Authorization
Expand Down Expand Up @@ -209,7 +215,7 @@ router.post("/signup", async (req, res) => {
// (1) ๊ณผ (3) ์‚ฌ์ด์— ๊ฐ™์€ ์ดˆ๋Œ€ํ‚ค๋กœ ๋™์‹œ ์š”์ฒญ์ด ๋“ค์–ด์˜ค๋ฉด ๋‘˜ ๋‹ค used=false ๋ฅผ ๋ณด๊ณ  ํ†ต๊ณผ โ†’ ํ‚ค 1๊ฐœ๋กœ N๋ช… ๊ฐ€์ž….
// updateMany({ where:{id, used:false}, data:{used:true} }) ๋Š” \"ํ•˜๋‚˜๋งŒ ํ†ต๊ณผ\" ๋ฅผ DB ๊ฐ€ ๋ณด์žฅํ•˜๋ฏ€๋กœ
// ํŠธ๋žœ์žญ์…˜ ์•ˆ์—์„œ ์ด ๊ฒฐ๊ณผ count ๋ฅผ ๋ณด๊ณ  ๋ถ„๊ธฐํ•˜๋ฉด ์–ด๋–ค ๋™์‹œ์„ฑ ์‹œ๋‚˜๋ฆฌ์˜ค์—์„œ๋„ ๋‹จ ํ•œ ๋ช…๋งŒ ๊ฐ€์ž…ํ•œ๋‹ค.
let user: { id: string; email: string; name: string; role: string; team: string | null; position: string | null; avatarColor: string; avatarUrl: string | null; superAdmin: boolean; companyId: string | null };
let user: { id: string; email: string; name: string; role: string; team: string | null; position: string | null; avatarColor: string; avatarUrl: string | null; superAdmin: boolean; companyId: string | null; platformAdmin: boolean; isDeveloper: boolean };
try {
user = await prisma.$transaction(async (tx) => {
const now = new Date();
Expand Down Expand Up @@ -246,6 +252,7 @@ router.post("/signup", async (req, res) => {
team: created.team, position: created.position,
avatarColor: created.avatarColor, avatarUrl: created.avatarUrl, superAdmin: created.superAdmin,
companyId: created.companyId,
platformAdmin: created.platformAdmin, isDeveloper: created.isDeveloper,
};
}, {
isolationLevel: "Serializable",
Expand Down Expand Up @@ -291,6 +298,10 @@ router.post("/signup", async (req, res) => {
avatarUrl: user.avatarUrl,
superAdmin: user.superAdmin,
consoleOnly: isConsoleOnlyUser(user),
// ๋กœ๊ทธ์ธ ์‘๋‹ต๊ณผ ๋™์ผ โ€” /api/me ์™€ ํ•„๋“œ ์ผ์น˜(#1113).
companyId: user.companyId ?? null,
platformAdmin: user.platformAdmin,
isDeveloper: user.isDeveloper,
},
// ๋กœ๊ทธ์ธ๊ณผ ๋™์ผ โ€” ๋„ค์ดํ‹ฐ๋ธŒ origin ์—๋งŒ ์„ธ์…˜ ํ† ํฐ์„ ๋ณธ๋ฌธ์œผ๋กœ ํ•จ๊ป˜ ๋‚ด๋ฆฐ๋‹ค.
...(isNativeOrigin(req) ? { token } : {}),
Expand Down
Loading