-
Notifications
You must be signed in to change notification settings - Fork 66
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
add auth support for solid start #1058
base: master
Are you sure you want to change the base?
Conversation
- formatting - clean up deps
There are some type issues in CreateAuthRouteHandlers (redirect function in solid router return a response, but other router maynot do the same thing), is replacing return types with unknown (or Response | never) a good solution? |
Amazing, thanks so much for the contribution! I'll take a closer look at it later today, but based on my initial light pass, it seems solid 😉
It seems idiomatic to |
solidjs/solid-start#1512 (comment) try {
// do something
} catch (err) {
if (err instanceof Response) {
return err
} else {
throw err
}
} If the code is not wrapped by a wrapper, it will cause an error. This may be a solid start issue. Therefore, it is safer to return a redirect if needed. export const { GET, POST } = serverAuthHelper.createAuthRouteHandlers({
async onBuiltinUICallback({ error, tokenData, isSignUp }) {
"use server"
if (error) {
console.error("Authentication failed: ", error)
return redirect("/error?error=auth-failed")
}
if (!tokenData) {
console.error("Email verification required.")
return redirect("/error?error=email-verification-required")
}
if (isSignUp) {
const client = serverAuthHelper.getSession({
tokenData,
}).client
const emailData = await client.querySingle<{ email: string }>(`
SELECT ext::auth::EmailFactor {
email
} FILTER .identity = (global ext::auth::ClientTokenIdentity)
`)
console.log("emailData: ", emailData)
await client.query(`
INSERT User {
name := '',
email := '${emailData?.email}',
userRole := 'user',
identity := (global ext::auth::ClientTokenIdentity)
}
`)
}
return redirect("/")
},
async onSignout() {
"use server"
throw redirect("/")
},
}) By the way, here's some code from react that needs to be cleaned up (e.g. handle actions, I didn't figure out how it works). |
Ahh, I see. Well, it's fine to return
Can you point out what needs to be cleaned up? That looks like example code, not library code. |
I mean the library (sorry for my English). The part need to clean up is: edgedb-js/packages/auth-solid-start/src/server/index.ts Lines 957 to 959 in f8e5af2
This may always be false. I think just need to remove them. |
- make package name consistent with others
template
Based on auth-nextjs and auth-remix, replace functions with corresponding alternatives. Tested on the template, capable of normal sign up, sign in, add and delete items, but no further extensive testing has been conducted.