跳轉到

Web 取得登入者資訊

說明如何透過 Settings 物件取得目前登入者的基本資料。

import { Settings } from '@uofx/core';

Settings.UserInfo 回傳的是 UofxUserProfileModel 物件,其定義如下:

/** 使用者基本資訊 */
interface UofxUserProfileModel {
    /** 帳號 */
    account: string;
    /** 姓名 */
    name: string;
    /** 公司 Id */
    corpId: string;
    /** 公司名稱 */
    corpName: string;
    /** 公司代號 */
    corpCode: string;
    /** 語系 */
    culture: string;
}

屬性說明

屬性名稱 型別 說明
account string 使用者帳號
name string 使用者姓名
corpId string 公司 ID (GUID)
corpName string 公司名稱
corpCode string 公司代號
culture string 目前語系 (例如: zh-TW)

使用範例

取得登入者帳號

const account = Settings.UserInfo.account;
console.log(account);

取得完整資訊

const userInfo = Settings.UserInfo;
console.log(`Hello, ${userInfo.name} from ${userInfo.corpName}`);