Skip to content

Commit

Permalink
logout
Browse files Browse the repository at this point in the history
  • Loading branch information
djyde committed Jul 12, 2023
1 parent d09f685 commit bbdba5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { UserSession } from "../service"
import NextLink from 'next/link'
import { useRouter } from "next/router"
import { SettingsIcon } from '@chakra-ui/icons'
import { AiOutlineLogout, AiOutlineSetting, AiOutlineFileText, AiOutlineAlert, AiOutlinePlus, AiOutlineComment, AiOutlineCode, AiOutlineRight, AiOutlineDown } from 'react-icons/ai'
import { AiOutlineLogout, AiOutlineSetting, AiOutlineFileText, AiOutlineAlert, AiOutlinePlus, AiOutlineComment, AiOutlineCode, AiOutlineRight, AiOutlineDown, AiOutlineFile } from 'react-icons/ai'
import { signout, signOut } from "next-auth/client"
import { Footer } from "./Footer"
import { createProject } from "../pages/getting-start"
Expand Down Expand Up @@ -168,6 +168,8 @@ export function MainLayout(props: {
<NavLink active={props.id === 'settings'} styles={styles} label="Site settings" icon={<AiOutlineSetting />}>
</NavLink>
</Link>
<NavLink component="a" href="/doc" target={'_blank'} label="Documentation" icon={<AiOutlineFileText />}>
</NavLink>
</Stack>

</Stack>
Expand Down Expand Up @@ -300,6 +302,9 @@ export function MainLayout(props: {
<Anchor size="sm">Manage subscription</Anchor>
</Stack>
<Button loading={updateUserSettingsMutation.isLoading} onClick={onClickSaveUserSettings}>Save</Button>
<Button onClick={_ => signOut()} variant={'outline'} color='red'>
Logout
</Button>
</Stack>
</Modal>
{props.children}
Expand Down
9 changes: 9 additions & 0 deletions pages/dashboard/project/[projectId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ export async function getServerSideProps(ctx) {
const project = await projectService.get(ctx.query.projectId) as Project
const viewDataService = new ViewDataService(ctx.req)

if (!session) {
return {
redirect: {
destination: '/dashboard',
permanent: false
}
}
}

if (project.deletedAt) {
return {
redirect: {
Expand Down

0 comments on commit bbdba5d

Please sign in to comment.