feat: hook syncUser to login callback
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -10,14 +10,10 @@ export enum Code {
|
||||
export type ApplicationError = ConvexError<{ code: Code; message: string }>
|
||||
|
||||
export function isApplicationError(error: unknown): error is ApplicationError {
|
||||
return (
|
||||
error instanceof ConvexError &&
|
||||
"code" in error.data &&
|
||||
"message" in error.data
|
||||
)
|
||||
return error instanceof ConvexError && "code" in error.data
|
||||
}
|
||||
|
||||
export function create(code: Code, message: string = "unknown error") {
|
||||
export function create(code: Code, message?: string) {
|
||||
return new ConvexError({
|
||||
code,
|
||||
message,
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import type { Id } from "../_generated/dataModel"
|
||||
import type { MutationCtx, QueryCtx } from "../_generated/server"
|
||||
import type { AuthenticatedMutationCtx } from "../functions"
|
||||
import * as Err from "./error"
|
||||
|
||||
/**
|
||||
@@ -36,3 +38,9 @@ export async function userOrThrow(ctx: QueryCtx | MutationCtx) {
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
export async function register(ctx: AuthenticatedMutationCtx) {
|
||||
await ctx.db.insert("users", {
|
||||
jwtSubject: ctx.identity.subject,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user