Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
user profile widget RELEASE (#39)
Browse files Browse the repository at this point in the history
* user profile widget

* CR fixes

* CR fixes

* CR fixes
  • Loading branch information
nirgur authored Apr 29, 2024
1 parent 37a713e commit b3740cf
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 183 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,34 @@ import { AuditManagement } from '@descope/nextjs-sdk';
Example:
[Manage Audit](./examples/app-router/app/manage-audit/page.tsx)

#### User Profile

The `UserProfile` widget lets you embed a user profile component in your app and let the logged in user update his profile.

The widget lets you:

- Update user profile picture
- Update user personal information
- Update authentication methods
- Logout

###### Usage

```js
import { UserProfile } from '@descope/nextjs-sdk';
...
<UserProfile
widgetId="user-profile-widget"
onLogout={() => {
// add here you own logout callback
window.location.href = '/login';
}}
/>
```

Example:
[User Profile](./examples/app-router/app/my-user-profile/page.tsx)

## Code Example

You can find an example react app in the [examples folder](./examples). - [App Router](/examples/app-router/) - [Pages Router](/examples/pages-router/)
Expand Down
21 changes: 21 additions & 0 deletions examples/app-router/app/my-user-profile/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { UserProfile } from '@descope/nextjs-sdk'; // eslint-disable-line

export default () => (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
}}
>
<h1>User Profile</h1>
<UserProfile
widgetId="user-profile-widget"
onLogout={() => {
window.location.href = '/login';
}}
/>
</div>
);
4 changes: 3 additions & 1 deletion examples/app-router/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Page = async () => {
<UserDetails />
<p>{!sessionRes ? 'User is not logged in' : 'User is logged in'}</p>
{
// show link to Manage Users, Roles, Audit, and Access Keys if user is logged in
// show link to Manage Users, Roles, Audit, User-Profile and Access Keys if user is logged in
true && (
<div>
<Link href="/manage-users">Manage Users</Link>
Expand All @@ -22,6 +22,8 @@ const Page = async () => {
<Link href="/manage-access-keys">Manage Access Keys</Link>
<br />
<Link href="/manage-audit">Manage Audit</Link>
<br />
<Link href="/user-profile">User Profile</Link>
</div>
)
}
Expand Down
Loading

0 comments on commit b3740cf

Please sign in to comment.