Skip to content

Commit

Permalink
Merge pull request #368 from refly-ai/fix/online-logout
Browse files Browse the repository at this point in the history
fix(api): enhance cookie management in auth service
  • Loading branch information
mrcfps authored Jan 14, 2025
2 parents 9ef0479 + 80ded9f commit cd0de5a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
11 changes: 10 additions & 1 deletion apps/api/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ export class AuthService {

const tokens = await this.login(payload);
this.setAuthCookie(res, tokens);
res.clearCookie(LEGACY_TOKEN_COOKIE);
res.clearCookie(LEGACY_TOKEN_COOKIE, {
domain: this.configService.get('auth.cookieDomain'),
secure: true,
sameSite: 'strict',
});
}

setAuthCookie(res: Response, { uid, accessToken, refreshToken }: TokenData) {
Expand Down Expand Up @@ -206,6 +210,11 @@ export class AuthService {
httpOnly: true,
secure: true,
sameSite: 'strict',
})
.clearCookie(LEGACY_TOKEN_COOKIE, {
domain: this.configService.get('auth.cookieDomain'),
secure: true,
sameSite: 'strict',
});
}

Expand Down
12 changes: 12 additions & 0 deletions apps/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
type="font/woff2"
crossorigin="anonymous" />
</head>
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-ER782LXJ5F"></script>
<script>
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag("js", new Date())

gtag("config", "G-ER782LXJ5F")
</script>
<body class="font-inter">
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { LuSettings, LuLogOut } from 'react-icons/lu';
import { useUserStore } from '@refly-packages/ai-workspace-common/stores/user';
import { useSiderStoreShallow } from '@refly-packages/ai-workspace-common/stores/sider';
import { useLogout } from '@refly-packages/ai-workspace-common/hooks/use-logout';

// styles
import { AiOutlineTwitter } from 'react-icons/ai';
import { IconDiscord } from '@refly-packages/ai-workspace-common/components/common/icon';

export const SiderMenuSettingList = (props: { children: React.ReactNode }) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -44,7 +42,7 @@ export const SiderMenuSettingList = (props: { children: React.ReactNode }) => {
},
{
key: 'getHelp',
icon: <AiOutlineTwitter />,
icon: <IconDiscord />,
label: t('loggedHomePage.siderMenu.getHelp'),
},
];
Expand All @@ -55,7 +53,7 @@ export const SiderMenuSettingList = (props: { children: React.ReactNode }) => {
} else if (key === 'logout') {
handleLogout();
} else if (key === 'getHelp') {
window.open(`https://twitter.com/reflyai`, '_blank');
window.open(`https://discord.gg/bWjffrb89h`, '_blank');
}
};

Expand Down

0 comments on commit cd0de5a

Please sign in to comment.