Woet
Woet
Explore posts from servers
KKinde
Created by TotalScrub on 12/23/2024 in #💻┃support
Refresh claims approach
Same for when deleting users
20 replies
KKinde
Created by TotalScrub on 12/23/2024 in #💻┃support
Refresh claims approach
@Stephen thanks for sharing! I think our needs to refresh claims are similar, so I'll take a look if this thread can help me. My exact use-case is that if an ADMIN changes the role of a user, that the change in permissions is reflected immediately for that user after changing the role. So what I think would need to happen, is that the change in roles done by the ADMIN user, needs to trigger a refresh of the claims for another user.
20 replies
KKinde
Created by TotalScrub on 12/23/2024 in #💻┃support
Refresh claims approach
Hey @Oli - Kinde , thanks for the response! I'm currently using the Next.js app router SDK
20 replies
KKinde
Created by TotalScrub on 12/23/2024 in #💻┃support
Refresh claims approach
Just came here to ask the exact same question, cause I'm having the same use-case as described above and want the user changes reflected immediately in my app instead of them only being reflected after logging out and back in again
20 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
But thanks for the help @Yoshify, appreciate it!
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
Hope so! 🤞
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
No description
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
No description
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
I think that's still causing some issues somewhere
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
I used to not give the user a last name
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
No description
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
So my auth in the middleware is a bit redundant?
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
import { cookies } from "next/headers";

import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";
import { redirect } from "next/navigation";

....

import { syncCachedAppUser } from "@/features/authentication/actions/syncAppUser";

export default async function FirmLayout({
children,
}: {
children: React.ReactNode;
}) {
const cookieStore = cookies();
const defaultOpen = cookieStore.get("sidebar:state")?.value === "true";

const {
getBooleanFlag,
getClaim,
isAuthenticated,
getUser,
getOrganization,
getPermissions,
} = getKindeServerSession();

const userOrganizationsClaim = await getClaim("organizations", "id_token");
const userOrganizations = (userOrganizationsClaim?.value ?? []) as {
id: string;
name: string;
}[];

const loggedIn = await isAuthenticated();
const kindeUser = await getUser();
const userOrganization = await getOrganization();
const orgCode = userOrganization?.orgCode;
const permissionsInfo = await getPermissions();
const permissions = permissionsInfo?.permissions ?? [];

// Check if user is logged in and belongs to an organization
if (!loggedIn || !orgCode) {
console.log("You are not authenticated");

redirect("/login");
}

// Check if user exists on Kinde
if (!kindeUser?.id || !kindeUser?.email) {
console.log("No valid user found");

redirect("/login");
}

// Sort the organizations by name
userOrganizations.sort((a, b) => a.name.localeCompare(b.name));

const mvpFeatureFlag = (await getBooleanFlag("mvp_features", true)) ?? false;
const dataWarehouseFeatureFlag =
(await getBooleanFlag("data_warehouse", true)) ?? false;

const { user } = await syncCachedAppUser(kindeUser, orgCode, permissions);

if (!user) {
redirect("/login");
}

return (
<>
...
</>
);
}
import { cookies } from "next/headers";

import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";
import { redirect } from "next/navigation";

....

import { syncCachedAppUser } from "@/features/authentication/actions/syncAppUser";

export default async function FirmLayout({
children,
}: {
children: React.ReactNode;
}) {
const cookieStore = cookies();
const defaultOpen = cookieStore.get("sidebar:state")?.value === "true";

const {
getBooleanFlag,
getClaim,
isAuthenticated,
getUser,
getOrganization,
getPermissions,
} = getKindeServerSession();

const userOrganizationsClaim = await getClaim("organizations", "id_token");
const userOrganizations = (userOrganizationsClaim?.value ?? []) as {
id: string;
name: string;
}[];

const loggedIn = await isAuthenticated();
const kindeUser = await getUser();
const userOrganization = await getOrganization();
const orgCode = userOrganization?.orgCode;
const permissionsInfo = await getPermissions();
const permissions = permissionsInfo?.permissions ?? [];

// Check if user is logged in and belongs to an organization
if (!loggedIn || !orgCode) {
console.log("You are not authenticated");

redirect("/login");
}

// Check if user exists on Kinde
if (!kindeUser?.id || !kindeUser?.email) {
console.log("No valid user found");

redirect("/login");
}

// Sort the organizations by name
userOrganizations.sort((a, b) => a.name.localeCompare(b.name));

const mvpFeatureFlag = (await getBooleanFlag("mvp_features", true)) ?? false;
const dataWarehouseFeatureFlag =
(await getBooleanFlag("data_warehouse", true)) ?? false;

const { user } = await syncCachedAppUser(kindeUser, orgCode, permissions);

if (!user) {
redirect("/login");
}

return (
<>
...
</>
);
}
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
I also have some auth checks in the layout of the project, could this be causing any conflicts: ´´´
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
Haven't been able to reproduce it yet when working with my development environment on Kinde
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
Logging things is a little bit of a hassle right now though, cause I only have the issue with my production environment
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
But doesn't seem to quite solve the issue yet
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
No description
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
No description
29 replies
KKinde
Created by Woet on 12/10/2024 in #💻┃support
Next.js - blocking error upon login when creating new organisations
I'll take a look
29 replies