Welcome to the Kinde community

C
Colin
Offline, last seen 2 months ago
Joined September 23, 2024
Hello, I am kinda new to working with Kinde and am planning on using it for my future projects as it has been a very nice experience till now.

I was trying to figure out the best way to access the management API from a Nuxt server route.

My current use case is to add a role to a user from a stripe subscription webhook.

It is written in the module's docs that the management API is a feature that has not yet seen the day but should still be accessible as it uses the Typescript SDK under the hood right?

Here is the project I am working on: https://github.com/ColinEspinas/starter

Have a wonderful day, Colin.
41 comments
C
D
Using the nuxt module for a while and wanted to implement custom login/sign-ups. For that as I understand I need to use the Kinde client (never used before on the frontend side).

Plain Text
const client = useKindeClient()

function test() {
  console.log(client) // used @click on a button and logs null
}


Also, the type returned by the useKindeClient composable is any, that seems super wrong to me.

Have a great day, Colin.

PS: Here is a link to my project repo (https://github.com/ColinEspinas/starter)
7 comments
C
D
A
Following https://discord.com/channels/1070212618549219328/1205374262878412810 and https://discord.com/channels/1070212618549219328/1204727161794338849

I've been having a hard time getting up to date data from the nuxt module when using the same methods as in the docs.

Here is a composition I've got to handle those operations:
Plain Text
export async function useUser() {
  const { user } = useAuth()
  const client = useKindeClient()

  const { data: permissions } = await useAsyncData(`permissions-${user?.id ?? 'guest'}`, async () => {
    const { permissions } = (await client?.getPermissions()) ?? {}
    return permissions as string[]
  })

  const getHasPermission = (permission: string) => {
    return permissions.value?.includes(permission) ?? false
  }

  const { data: roles, refresh: refreshRoles } = await useAsyncData(`roles-${user?.id ?? 'guest'}`, async () => {
    const { value } = (await client?.getClaim('roles')) ?? {}
    return value as { id: string, key: string, name: string }[]
  })

  const getHasRole = (role: string) => {
    return roles.value?.some(r => r.key === role) ?? false
  }

  const { data: organization } = await useAsyncData(`organization-${user?.id ?? 'guest'}`, async () => {
    const { orgCode } = (await client?.getOrganization()) ?? {}
    return orgCode as string
  })

  return {
    permissions,
    roles,
    organization,
    getHasPermission,
    getHasRole,
    refreshRoles,
  }
}

At first I thought it was something to do with the tokens not being refreshed after the update but that does not make much sense as the data for permissions should not be in the token right?

Anyway, I've not had any success in updating the user data. Am I doing something wrong or missing a piece?
12 comments
C
D
d
A