Skip to content

Commit

Permalink
make optional param disable redirect
Browse files Browse the repository at this point in the history
adds JSdoc comment syntax to give info about the param
  • Loading branch information
buckhalt committed May 3, 2024
1 parent 778a99c commit 0693003
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions actions/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ export async function login(formData: FormData) {

return redirect('/dashboard');
}
/**
* @param disableRedirect If true, does not redirect to the homepage after logging out
*/

export async function logout(shouldRedirect?: boolean) {
export async function logout(disableRedirect?: boolean) {
const { session } = await getServerSession();
if (!session) {
return {
Expand All @@ -114,9 +117,9 @@ export async function logout(shouldRedirect?: boolean) {
sessionCookie.attributes,
);

if (shouldRedirect) {
return redirect('/');
if (disableRedirect) {
return;
}

return;
return redirect('/');
}
2 changes: 1 addition & 1 deletion app/dashboard/_components/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SubmitButton from '~/components/ui/SubmitButton';

const UserMenu = () => {
return (
<form action={() => logout(true)}>
<form action={() => logout()}>
<SubmitButton variant="secondary" size="sm" type="submit">
Sign out
</SubmitButton>
Expand Down
2 changes: 1 addition & 1 deletion components/Feedback/SignOutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const SignOutModal = ({
<AlertDialogCancel onClick={() => setOpenSignOutModal(false)}>
Cancel
</AlertDialogCancel>
<AlertDialogAction onClick={() => void logout()}>
<AlertDialogAction onClick={() => void logout(true)}>
Sign Out and Hide Banner
</AlertDialogAction>
</AlertDialogFooter>
Expand Down

0 comments on commit 0693003

Please sign in to comment.