<User />
The User component of the WSO2 Identity Server Vue SDK (@asgardeo/vue) gives your template access to the signed-in user through a scoped slot.
Overview
User reads user from the authentication context. When a user is available, it renders its default slot and passes the user as the slot prop user. Otherwise, it renders the fallback slot, or nothing if you don't provide one.
The user object holds the attributes of the user's WSO2 Identity Server profile, read from the SCIM 2.0 /scim2/Me endpoint, for example userName, name.givenName and emails. If the SDK can't read the profile, the object holds the claims of the user's ID token instead.
Usage
The following examples show how to use User.
Basic usage
<script setup>
import { User } from '@asgardeo/vue'
</script>
<template>
<User v-slot="{ user }">
<p>Signed in as {{ user.userName }}</p>
</User>
</template>
With a fallback
When you use more than one slot, use <template> tags.
<template>
<User>
<template #default="{ user }">
<p>Hello, {{ user.name?.givenName }}!</p>
</template>
<template #fallback>
<p>Please sign in.</p>
</template>
</User>
</template>
Props
User has no props.
Slots
| Slot | Slot props | Description |
|---|---|---|
default | { user } | Content to render when a user is available. |
fallback | — | Content to render when no user is available. |
To read the user in your script, use user from useAsgardeo(), or the profile from useUser().
Was this page helpful?