|
| 1 | +--- |
| 2 | +description: Learn how to use Logto's prebuilt Account Center UI to let users manage their accounts |
| 3 | +sidebar_position: 2 |
| 4 | +--- |
| 5 | + |
| 6 | +# Account settings by prebuilt Account Center UI |
| 7 | + |
| 8 | +## What is the prebuilt Account Center UI \{#what-is-the-prebuilt-account-center-ui} |
| 9 | + |
| 10 | +Logto provides a prebuilt Account Center UI that offers ready-to-use pages for end users to manage their account settings. This prebuilt UI is hosted by Logto and handles common account management tasks including: |
| 11 | + |
| 12 | +- Updating email address |
| 13 | +- Updating phone number |
| 14 | +- Updating username |
| 15 | +- Setting or updating password |
| 16 | +- Managing MFA settings (TOTP authenticator app, passkeys, backup codes) |
| 17 | + |
| 18 | +The prebuilt Account Center UI is designed to work seamlessly with your application, providing a consistent user experience without requiring you to build custom account management pages. |
| 19 | + |
| 20 | +## Benefits of using the prebuilt UI \{#benefits-of-using-the-prebuilt-ui} |
| 21 | + |
| 22 | +- **Zero development effort**: Ready-to-use pages that work out of the box |
| 23 | +- **Consistent experience**: Matches the look and feel of Logto's sign-in experience |
| 24 | +- **Security built-in**: All verification flows and security measures are handled automatically |
| 25 | +- **Always up-to-date**: New features and security improvements are automatically available |
| 26 | + |
| 27 | +## Available pages \{#available-pages} |
| 28 | + |
| 29 | +The prebuilt Account Center UI provides the following pages, all accessible under the `/account` path of your Logto tenant endpoint: |
| 30 | + |
| 31 | +| Path | Description | |
| 32 | +| -------------------------------- | --------------------------------- | |
| 33 | +| `/account/email` | Update primary email address | |
| 34 | +| `/account/phone` | Update primary phone number | |
| 35 | +| `/account/username` | Update username | |
| 36 | +| `/account/password` | Set or update password | |
| 37 | +| `/account/passkey/add` | Add a new passkey (WebAuthn) | |
| 38 | +| `/account/passkey/manage` | View and manage existing passkeys | |
| 39 | +| `/account/authenticator-app` | Set up TOTP authenticator app | |
| 40 | +| `/account/backup-codes/generate` | Generate new backup codes | |
| 41 | +| `/account/backup-codes/manage` | View and manage backup codes | |
| 42 | + |
| 43 | +For example, if your tenant endpoint is `https://example.logto.app`, the email update page would be available at `https://example.logto.app/account/email`. |
| 44 | + |
| 45 | +## How to use the prebuilt UI \{#how-to-use-the-prebuilt-ui} |
| 46 | + |
| 47 | +### Step 1: Enable Account API \{#step-1-enable-account-api} |
| 48 | + |
| 49 | +The prebuilt Account Center UI relies on the Account API. Navigate to <CloudLink to="/sign-in-experience/account-center">Console > Sign-in & account > Account center</CloudLink> and enable the Account API. |
| 50 | + |
| 51 | +Configure the field permissions according to your needs: |
| 52 | + |
| 53 | +- Set fields to `Edit` to allow users to modify them |
| 54 | +- Set fields to `ReadOnly` if users should only view them |
| 55 | +- Set fields to `Off` to hide them completely |
| 56 | + |
| 57 | +### Step 2: Link to prebuilt pages from your application \{#step-2-link-to-prebuilt-pages} |
| 58 | + |
| 59 | +To use the prebuilt Account Center UI, you need to redirect users from your application to the appropriate Logto pages. There are two approaches: |
| 60 | + |
| 61 | +#### Approach A: Direct linking with redirect parameter \{#approach-a-direct-linking} |
| 62 | + |
| 63 | +Add links in your application that redirect users to the prebuilt pages. Include a `redirect` query parameter to bring users back to your app after they complete the action: |
| 64 | + |
| 65 | +``` |
| 66 | +https://[tenant-id].logto.app/account/email?redirect=https://your-app.com/settings |
| 67 | +``` |
| 68 | + |
| 69 | +When users complete updating their email, they will be redirected back to `https://your-app.com/settings`. |
| 70 | + |
| 71 | +#### Approach B: Embedding in your account settings flow \{#approach-b-embedding} |
| 72 | + |
| 73 | +You can integrate the prebuilt pages into your existing account settings workflow: |
| 74 | + |
| 75 | +1. In your app's account settings page, show the user's current information |
| 76 | +2. Provide "Edit" or "Update" buttons that link to the corresponding prebuilt pages |
| 77 | +3. After the user completes the action, they are redirected back to your app |
| 78 | + |
| 79 | +Example implementation: |
| 80 | + |
| 81 | +```tsx |
| 82 | +function AccountSettings() { |
| 83 | + const tenantEndpoint = 'https://example.logto.app'; |
| 84 | + const redirectUrl = encodeURIComponent(window.location.href); |
| 85 | + |
| 86 | + return ( |
| 87 | + <div> |
| 88 | + <h2>Account Settings</h2> |
| 89 | + |
| 90 | + <div> |
| 91 | + <span>Email: user@example.com</span> |
| 92 | + <a href={`${tenantEndpoint}/account/email?redirect=${redirectUrl}`}>Update Email</a> |
| 93 | + </div> |
| 94 | + |
| 95 | + <div> |
| 96 | + <span>Password: ••••••••</span> |
| 97 | + <a href={`${tenantEndpoint}/account/password?redirect=${redirectUrl}`}>Change Password</a> |
| 98 | + </div> |
| 99 | + |
| 100 | + <div> |
| 101 | + <span>MFA: Not configured</span> |
| 102 | + <a href={`${tenantEndpoint}/account/authenticator-app?redirect=${redirectUrl}`}> |
| 103 | + Set up Authenticator |
| 104 | + </a> |
| 105 | + </div> |
| 106 | + </div> |
| 107 | + ); |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +### Step 3: Handle success redirects \{#step-3-handle-success-redirects} |
| 112 | + |
| 113 | +After users complete an action, they will be redirected to your specified URL with an optional `show_success` query parameter. You can use this to display a success message: |
| 114 | + |
| 115 | +```tsx |
| 116 | +function SettingsPage() { |
| 117 | + const searchParams = new URLSearchParams(window.location.search); |
| 118 | + const showSuccess = searchParams.get('show_success'); |
| 119 | + |
| 120 | + return ( |
| 121 | + <div> |
| 122 | + {showSuccess === 'email' && <div>Email updated successfully!</div>} |
| 123 | + {showSuccess === 'password' && <div>Password updated successfully!</div>} |
| 124 | + {/* ... rest of your settings page */} |
| 125 | + </div> |
| 126 | + ); |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +## Security considerations \{#security-considerations} |
| 131 | + |
| 132 | +The prebuilt Account Center UI includes built-in security measures: |
| 133 | + |
| 134 | +- **Identity verification**: Before making sensitive changes (email, phone, password, MFA), users must verify their identity using their current password or existing verification method |
| 135 | +- **Verification codes**: Email and phone updates require verification codes sent to the new address/number |
| 136 | +- **Session validation**: All operations validate the user's session to prevent unauthorized access |
| 137 | + |
| 138 | +## Customization options \{#customization-options} |
| 139 | + |
| 140 | +The prebuilt Account Center UI inherits the branding from your sign-in experience settings, including: |
| 141 | + |
| 142 | +- Logo and colors |
| 143 | +- Dark/light mode |
| 144 | +- Language settings |
| 145 | + |
| 146 | +If you need more customization beyond what the prebuilt UI offers, consider using the [Account API](/end-user-flows/account-settings/by-account-api) to build your own custom account management pages. |
| 147 | + |
| 148 | +## Related resources \{#related-resources} |
| 149 | + |
| 150 | +- [Account settings by Account API](/end-user-flows/account-settings/by-account-api) - Build custom account management with full API control |
| 151 | +- [Account settings by Management API](/end-user-flows/account-settings/by-management-api) - Admin-level account management |
| 152 | +- [MFA configuration](/end-user-flows/mfa) - Set up multi-factor authentication |
0 commit comments