User
User — a class for working with the current user inside the installed mini‑application: checking permissions and roles, accessing their settings (UserOptions) and other related data. Singleton instance is available after Frame initialization.
ts
import { User } from '@aspro-cloud/miniapp-jssdk'Properties
options
UserOptions instance for managing current user settings
ts
get options(): UserOptionsMethods
getInstance
Returns the current singleton instance of User. Call only after Frame initialization
ts
static getInstance(): Userdestroy
Removes subscriptions and releases resources
ts
destroy(): voidhasRole
Checks whether the current user has at least one of the specified roles in the installed mini‑application
ts
async hasRole(role: UserRole | UserRole[]): Promise<boolean>| Parameter | Type | Description |
|---|---|---|
role | UserRole | UserRole[] | A single role or an array of roles to check ('admin', 'employee', 'none') |
isAdmin
Returns true if the current user is a portal administrator
ts
async isAdmin(): Promise<boolean>Example
ts
import { App, User } from '@aspro-cloud/miniapp-jssdk'
await App.initializeFrame()
const user = User.getInstance()
// check whether the current user is a portal administrator
if (await user.isAdmin()) {
console.log('User is a portal administrator')
}
// check the role of the current user
if (await user.hasRole('admin')) {
console.log('The current user has the administrator role in the application')
}js
const App = window.ACloudMiniApp;
const frame = await App.initializeFrame();
// check whether the current user is a portal administrator
if (await frame.user.isAdmin()) {
console.log('User is a portal administrator');
}
// check the role of the current user
if (await frame.user.hasRole('admin')) {
console.log('The current user has the administrator role in the application');
}