Skip to main content
Version: 1.0.0

Overview

The @abpjs/account-pro package provides advanced account management components and services for ABP React applications. This is the React equivalent of Angular's @volo/abp.ng.account module.

Installation

npm install @abpjs/account-pro
# or
yarn add @abpjs/account-pro

Features

  • Login & Registration - Complete authentication flows with customizable forms
  • Multi-tenancy Support - Built-in tenant switching with TenantBox component
  • Password Management - Forgot password, reset password, and change password flows
  • Profile Management - Personal settings and profile update functionality
  • OAuth Integration - Resource Owner Password Credentials (ROPC) flow support
  • Two-Factor Authentication - Optional 2FA support (Pro feature)
  • Social Logins - Optional social login providers (Pro feature)

Setup

Wrap your application with the AccountProProvider:

import { AccountProProvider } from '@abpjs/account-pro';

function App() {
return (
<AccountProProvider options={{
redirectUrl: '/dashboard',
enableTwoFactor: true
}}>
<YourApp />
</AccountProProvider>
);
}

Configuration Options

OptionTypeDefaultDescription
redirectUrlstring'/'URL to redirect after successful login
redirectToLoginbooleantrueRedirect to login on 401 errors
loginUrlstring'/account/login'Custom login page URL
registerUrlstring'/account/register'Custom registration page URL
enableSocialLoginsbooleanfalseEnable social login providers
enableTwoFactorbooleanfalseEnable two-factor authentication

Components

LoginForm

The main login form component with support for tenant switching and remember me functionality.

import { LoginForm } from '@abpjs/account-pro';

function LoginPage() {
return (
<LoginForm
showTenantBox={true}
showRegisterLink={true}
showForgotPasswordLink={true}
/>
);
}

Props:

PropTypeDefaultDescription
showTenantBoxbooleantrueShow tenant switching UI
showRegisterLinkbooleantrueShow link to registration page
showForgotPasswordLinkbooleantrueShow forgot password link

RegisterForm

User registration form with validation.

import { RegisterForm } from '@abpjs/account-pro';

function RegisterPage() {
return <RegisterForm />;
}

TenantBox

Component for switching between tenants in a multi-tenant application.

import { TenantBox } from '@abpjs/account-pro';

function Header() {
return <TenantBox />;
}

ForgotPassword

Password recovery form that sends reset codes via email.

import { ForgotPassword } from '@abpjs/account-pro';

function ForgotPasswordPage() {
return <ForgotPassword />;
}

ResetPassword

Form for resetting password using the token received via email.

import { ResetPassword } from '@abpjs/account-pro';

function ResetPasswordPage() {
return <ResetPassword />;
}

ChangePassword

Form for authenticated users to change their password.

import { ChangePassword } from '@abpjs/account-pro';

function ChangePasswordPage() {
return <ChangePassword />;
}

PersonalSettings

Form for updating user profile information.

import { PersonalSettings } from '@abpjs/account-pro';

function PersonalSettingsPage() {
return <PersonalSettings />;
}

ManageProfile

Container component for profile management with navigation tabs.

import { ManageProfile } from '@abpjs/account-pro';

function ManageProfilePage() {
return <ManageProfile />;
}

Hooks

usePasswordFlow

Hook for handling OAuth Resource Owner Password Credentials flow.

import { usePasswordFlow } from '@abpjs/account-pro';

function CustomLoginForm() {
const { login, isLoading, error, clearError } = usePasswordFlow();

const handleSubmit = async (data) => {
const success = await login(data.username, data.password, data.rememberMe);
if (success) {
// Handle successful login
}
};

return (
<form onSubmit={handleSubmit}>
{error && <div className="error">{error}</div>}
{/* Form fields */}
</form>
);
}

Returns:

PropertyTypeDescription
login(username, password, rememberMe?) => Promise<boolean>Perform login
isLoadingbooleanLoading state
errorstring | nullError message
clearError() => voidClear error state

useAccountProService

Hook to access the AccountProService for API operations.

import { useAccountProService } from '@abpjs/account-pro';

function TenantLookup() {
const accountService = useAccountProService();

const lookupTenant = async (tenantName) => {
const result = await accountService.findTenant(tenantName);
if (result.success) {
console.log('Tenant found:', result.tenantId);
}
};
}

useAccountProOptions

Hook to access account configuration options.

import { useAccountProOptions } from '@abpjs/account-pro';

function MyComponent() {
const options = useAccountProOptions();

return (
<div>
Redirect URL: {options.redirectUrl}
</div>
);
}

Services

AccountProService

Service class for account-related API operations.

Methods:

MethodParametersReturnsDescription
findTenanttenantName: stringPromise<TenantIdResponse>Find tenant by name
registerbody: RegisterRequestPromise<RegisterResponse>Register new user
sendPasswordResetCodebody: SendPasswordResetCodeRequestPromise<void>Send password reset email
resetPasswordbody: ResetPasswordRequestPromise<void>Reset password with token
changePasswordbody: ChangePasswordRequestPromise<void>Change password (authenticated)
getProfile-Promise<ProfileResponse>Get current user profile
updateProfilebody: UpdateProfileRequestPromise<ProfileResponse>Update user profile

Routes

The package provides pre-configured routes:

import { ACCOUNT_PRO_ROUTES, ACCOUNT_PRO_PATHS } from '@abpjs/account-pro';

// Route structure:
// /account (invisible, uses account layout)
// /account/login
// /account/register
// /account/forgot-password
// /account/reset-password
// /account/manage-profile
// /account/manage-profile/change-password
// /account/manage-profile/personal-settings

// Use ACCOUNT_PRO_PATHS for navigation:
navigate(ACCOUNT_PRO_PATHS.login); // '/account/login'
navigate(ACCOUNT_PRO_PATHS.register); // '/account/register'
navigate(ACCOUNT_PRO_PATHS.forgotPassword); // '/account/forgot-password'
navigate(ACCOUNT_PRO_PATHS.resetPassword); // '/account/reset-password'
navigate(ACCOUNT_PRO_PATHS.manageProfile); // '/account/manage-profile'
navigate(ACCOUNT_PRO_PATHS.changePassword); // '/account/manage-profile/change-password'
navigate(ACCOUNT_PRO_PATHS.personalSettings);// '/account/manage-profile/personal-settings'

TypeScript Support

The package exports all TypeScript interfaces:

import type {
AccountOptions,
LoginFormData,
RegisterFormData,
TenantInfo,
TenantIdResponse,
RegisterRequest,
RegisterResponse,
SendPasswordResetCodeRequest,
ResetPasswordRequest,
ChangePasswordRequest,
ChangePasswordFormData,
ForgotPasswordFormData,
ResetPasswordFormData,
PersonalSettingsFormData,
UpdateProfileRequest,
ProfileResponse,
PasswordFlowResult,
} from '@abpjs/account-pro';

Dependencies

  • @abpjs/core - Core ABP React functionality

Comparison with @abpjs/account

Feature@abpjs/account@abpjs/account-pro
Login FormYesYes
Register FormYesYes
Tenant BoxYesYes
Forgot PasswordNoYes
Reset PasswordNoYes
Change PasswordNoYes
Personal SettingsNoYes
Profile ManagementNoYes
Two-Factor AuthNoYes
Social LoginsNoYes

See Also