Skip to content

Commit

Permalink
Merge pull request #7 from chedakr/feature/delete-options
Browse files Browse the repository at this point in the history
chore: 쿠키 지우기 옵션 추가
  • Loading branch information
Xvezda authored May 16, 2024
2 parents cd1cb8d + 3568279 commit bc80b38
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions apps/api/src/services/auth/v1/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ const withPrevUrl: MiddlewareHandler<{

prevUrl = payload['http:cheda.kr/state'].url;

deleteCookie(c, 'state');
deleteCookie(c, 'state', {
httpOnly: true,
...c.env.DEV ? {} : {
secure: true,
domain: '.cheda.kr',
},
});
}
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -173,8 +179,21 @@ const decryptToken = async <C extends Context = Context>(context: C, token: stri
};

const deleteSessionCookies = (c: Context) => {
deleteCookie(c, 'session_id');
deleteCookie(c, 'session_sid');
deleteCookie(c, 'session_id', {
sameSite: 'None',
secure: true,
...c.env.DEV ? {} : {
domain: '.cheda.kr',
},
});
deleteCookie(c, 'session_sid', {
httpOnly: true,
sameSite: 'None',
secure: true,
...c.env.DEV ? {} : {
domain: '.cheda.kr',
},
});
};

const withSession: MiddlewareHandler<{
Expand Down Expand Up @@ -349,7 +368,13 @@ app.get('/callback', async (c) => {
console.error(e);
/* noop */
} finally {
deleteCookie(c, 'state');
deleteCookie(c, 'state', {
httpOnly: true,
...c.env.DEV ? {} : {
secure: true,
domain: '.cheda.kr',
},
});
}

if (!state) {
Expand Down

0 comments on commit bc80b38

Please sign in to comment.