feat: add Clerk Auth #43
BIN
bun.lockb
|
|
@ -3,10 +3,10 @@
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun validate-env && bun database:up && bun prisma:generate && bun prisma:push && vite dev",
|
"dev": "bun validate-env && bun database:up && bun prisma:generate && vite dev",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"build-storybook": "storybook build",
|
"build-storybook": "storybook build",
|
||||||
"database:up": "docker compose -p hestia -f devops/docker-compose.dev.yml up -d && docker compose -p hestia -f devops/docker-compose.dev.yml -f devops/docker-compose.wait.yml run --rm wait -c hestia-database:5432",
|
"database:up": "docker compose -p hestia -f devops/docker-compose.dev.yml up -d && docker compose -p hestia -f devops/docker-compose.dev.yml -f devops/docker-compose.wait.yml run --rm wait -c hestia-database:5432 && bun prisma:push",
|
||||||
"database:down": "docker compose -p hestia -f devops/docker-compose.dev.yml down",
|
"database:down": "docker compose -p hestia -f devops/docker-compose.dev.yml down",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
|
|
@ -65,8 +65,7 @@
|
||||||
"vitest": "^2.0.4"
|
"vitest": "^2.0.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clerk/clerk-js": "^5.43.4",
|
"@clerk/backend": "1.21.4",
|
||||||
"@clerk/express": "^1.3.31",
|
|
||||||
"@clerk/themes": "^2.2.3",
|
"@clerk/themes": "^2.2.3",
|
||||||
"@flaticon/flaticon-uicons": "^3.3.1",
|
"@flaticon/flaticon-uicons": "^3.3.1",
|
||||||
"@inlang/paraglide-sveltekit": "^0.15.0",
|
"@inlang/paraglide-sveltekit": "^0.15.0",
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `password` on the `User` table. All the data in the column will be lost.
|
|
||||||
- You are about to drop the `Session` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "Session" DROP CONSTRAINT "Session_userId_fkey";
|
|
||||||
|
|
||||||
-- DropIndex
|
|
||||||
DROP INDEX "User_email_key";
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "User" DROP COLUMN "password";
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "Session";
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- Added the required column `clerkId` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "User" ADD COLUMN "clerkId" TEXT NOT NULL;
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the column `password` on the `User` table. All the data in the column will be lost.
|
||||||
|
- You are about to drop the `Session` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- A unique constraint covering the columns `[clerkId]` on the table `User` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
- Added the required column `clerkId` to the `User` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "Session" DROP CONSTRAINT "Session_userId_fkey";
|
||||||
|
|
||||||
|
-- DropIndex
|
||||||
|
DROP INDEX "User_email_key";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "User" DROP COLUMN "password",
|
||||||
|
ADD COLUMN "clerkId" TEXT NOT NULL;
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "Session";
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "User_clerkId_key" ON "User"("clerkId");
|
||||||
|
|
@ -16,7 +16,7 @@ datasource db {
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
clerkId String
|
clerkId String @unique
|
||||||
|
|
||||||
email String?
|
email String?
|
||||||
name String
|
name String
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
|
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
import { redirect, type ServerLoadEvent } from '@sveltejs/kit';
|
import { redirect, type ServerLoadEvent } from '@sveltejs/kit';
|
||||||
import { prisma } from '../prisma';
|
import { prisma } from '../prisma';
|
||||||
import { createClerkClient } from '@clerk/express';
|
import { createClerkClient } from '@clerk/backend';
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
import { CLERK_SECRET_KEY } from '$env/static/private';
|
import { CLERK_SECRET_KEY } from '$env/static/private';
|
||||||
import { clerkClient } from 'clerk-sveltekit/server';
|
import { clerkClient } from 'clerk-sveltekit/server';
|
||||||
|
import { logger } from '$lib/server/logger';
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
|
||||||
const clerkSessionClient = createClerkClient({
|
const clerkSessionClient = createClerkClient({
|
||||||
secretKey: CLERK_SECRET_KEY,
|
secretKey: CLERK_SECRET_KEY,
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function validateSession({ locals }: ServerLoadEvent) {
|
export async function validateSession({ locals }: ServerLoadEvent) {
|
||||||
if (!locals.auth.userId) {
|
if (!locals.auth.userId || !locals.auth.sessionId) {
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
return redirect(307, '/login');
|
return redirect(307, '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,13 +29,24 @@ export async function validateSession({ locals }: ServerLoadEvent) {
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
if (clerkUser.emailAddresses.length === 0) {
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
logger.error('User has no email address');
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
await clerkSessionClient.sessions.revokeSession(locals.auth.sessionId);
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
return redirect(307, '/login');
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
}
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
user = await prisma.user.create({
|
user = await prisma.user.create({
|
||||||
data: {
|
data: {
|
||||||
clerkId: clerkUser.id,
|
clerkId: clerkUser.id,
|
||||||
email: clerkUser.emailAddresses[0].emailAddress,
|
email: clerkUser.emailAddresses[0].emailAddress,
|
||||||
name: clerkUser.fullName ?? 'Ben the Man',
|
name: clerkUser.fullName ?? '',
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
if (clerkUser.fullName === null) {
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
logger.error('User has no name');
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
}
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
??? ???
don't like that 😉 ? don't like that 😉 ?
Why are we using clerk/express? Why are we using clerk/express?
Because clerk is deprecating the nodejs package and is recommending to use this one for backend Because clerk is deprecating the nodejs package and is recommending to use this one for backend
WE ARE PROFESSIONALS HERE MOE WE ARE PROFESSIONALS HERE MOE
I will change it to an empty string, I thought we were fun professionals I will change it to an empty string, I thought we were fun professionals
is the user fullName optional...? I'd rather not default to a magic string is the user fullName optional...? I'd rather not default to a magic string
If there is a situation where name will be empty/undefined consider changing the db schema If there is a situation where name will be empty/undefined consider changing the db schema
|
|||||||
|
|
@ -26,6 +26,9 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Can you explain what this is doing? Can you explain what this is doing?
I will add some comment, it is automatically selecting the first organization that the user is part of, if you don't do that the user get login without an organization I will add some comment, it is automatically selecting the first organization that the user is part of, if you don't do that the user get login without an organization
It would be better to do this check on the server to prevent anything from being leaked to the client side, you can use It would be better to do this check on the server to prevent anything from being leaked to the client side, you can use `+layout.server.ts`. We could throw an error, `403 - User does not belong to a Tenant`
I am already logging out the user on the backend, this is only selecting an org for him I am already logging out the user on the backend, this is only selecting an org for him
Also, modify the error page to contain a signout button, perhaps under certain http codes (like 403) Also, modify the error page to contain a signout button, perhaps under certain http codes (like 403)
|
|||||||
|
/**
|
||||||
|
* Set the active organization to the first one in the list, this is temporary until we let the user choose the organization
|
||||||
|
*/
|
||||||
try {
|
try {
|
||||||
// Set the active organization to the first one in the list
|
// Set the active organization to the first one in the list
|
||||||
await clerk.setActive({
|
await clerk.setActive({
|
||||||
|
|
|
||||||
???