-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request to fix (#117), user cannot sign out during create_profile sec… #118
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { redirect } from "@sveltejs/kit" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can just delete this change (see above comment) |
||
|
||
export const actions = { | ||
default: async ({ locals: { supabase, safeGetSession } }) => { | ||
const { session } = await safeGetSession() | ||
if (session) { | ||
await supabase.auth.signOut() | ||
} | ||
redirect(303, "/") | ||
Comment on lines
+4
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for the sign-out operation. Currently, the export const actions = {
default: async ({ locals: { supabase, safeGetSession } }) => {
const { session } = await safeGetSession()
if (session) {
try {
await supabase.auth.signOut()
} catch (error) {
console.error("Error signing out:", error)
// Optionally, handle the error by redirecting to an error page or displaying a message
}
}
redirect(303, "/")
},
} |
||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good implementation of sign-out using a form.
The use of a form with a POST method for signing out aligns with best practices. Ensure that any errors during form submission are handled and communicated to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just use the sign out link format we use elsewhere:
<a href="/account/sign_out" class="link">Sign Out</a>
No need to add a new endpoint.
POST does make sense, but don't want to fragment it and have a mix of methods across the template.
Sounds good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scosman, that makes sense. Consistency across the application is important, and using the same sign-out link format helps maintain that. Reverting to the anchor tag format as used elsewhere is a good approach. Let me know if there's anything else you'd like to adjust!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the preference for consistency. However the current approach of using
<a href="/account/sign_out" class="link">Sign Out</a>
is not working on the create_profile page. I think due to the differences in how SvelteKit handles page navigation between layouts and individual pages.
I'm quite new to SvelteKit and this template so I could be wrong; happy to discuss further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.