UNPKG

vix-ui

Version:

A set of essential UI modules for your Angular application in ViSenze

107 lines (106 loc) 2.86 kB
import { OAuthService } from 'angular-oauth2-oidc'; import { AuthConfigService } from './auth-config.service'; import { OktaService } from './okta.service'; import { UserInfo } from '../modules/user-info'; import { UserGroups } from '../modules/user-groups'; /** * VixAuthService is the interface exported to users. It wraps all API and methods. */ export declare class VixAuthService { private oauth; private authConfig; private okta; private oktaAuth; constructor(oauth: OAuthService, authConfig: AuthConfigService, okta: OktaService); /** * Check permissions by userGroups and requireGroups * * @param userGroups groups users are in * @param requireGroups groups application requires user to have * @returns true/false */ static hasPermission(userGroups: UserGroups, requireGroups: string[]): boolean; /** * Use tokenManager to store userId * TODO: actually I have problems in create a cache object to hold all these cache variables, so I use tokenManager to do these works. * TODO: need to create a share service to provide cache service * * @param userId */ setUserId(userId: string): void; /** * Get userId from tokenManager * @returns */ getUserId(): any; /** * Store userGroup and shared among browsers by TokenManager with key 'userGroup' * * @param userGroups */ setCurrentUserGroups(userGroups: UserGroups): void; /** * Get stored userGroups and refresh if expires * * @returns */ getLoginUserGroups(): Promise<UserGroups>; /** * Get current login userInfo * TODO: we can cache user info includes groups information when finished login * * @returns */ getUserInfo(): Promise<UserInfo>; /** * get userGroup by given userId * * @param userId * @returns */ getUserGroups(userId: string): Promise<UserGroups>; /** * Return if already login by check the existence of accessToken * * @returns */ isLogin(): any; /** * Redirect to url for Google login */ loginWithGoogle(redirectUrl: string): void; /** * Login by username and password * * @param username * @param password * @returns */ loginWithPassword(username: string, password: string): Promise<any>; /** * List all groups * * @returns */ listGroups(): Promise<Object>; /** * Get session * * @returns */ getSession(): Promise<any>; /** * Navigate browser to login page */ navigateToLoginPage(): void; /** * Navigate browser to redirect page */ navigateToRedirectPage(): void; /** * Logout current user and clear token * * @returns */ logout(): void; }