vix-ui
Version:
93 lines (92 loc) • 2.89 kB
TypeScript
import { OAuthService } from 'angular-oauth2-oidc';
import { AuthConfigService } from './auth-config.service';
import { OktaService } from './okta.service';
import { UserInfo } from './user-info';
import { UserGroups } from './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
*/
setUserId(userId: string): void;
/**
* 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
*/
setSessionToken(sessionToken: string): void;
/**
* Get userId from tokenManager
*/
getUserId(): any;
/**
* Get acess token
*/
getSessionToken(): any;
/**
* Store userGroup and shared among browsers by TokenManager with key 'userGroup'
*/
setCurrentUserGroups(userGroups: UserGroups): void;
/**
* Get stored userGroups and refresh if expires
*/
getLoginUserGroups(): Promise<UserGroups>;
/**
* Get current login userInfo
* TODO: we can cache user info includes groups information when finished login
*/
getUserInfo(): Promise<UserInfo>;
/**
* get userGroup by given userId
*/
getUserGroups(userId: string): Promise<UserGroups>;
/**
* Return if already login by check the existence of accessToken
*/
isLogin(): any;
/**
* Redirect to url for Google login
*/
loginWithGoogle(redirectUrl: string): void;
/**
* Login by username and password
*/
loginWithPassword(username: string, password: string): Promise<any>;
/**
* List all groups
*/
listGroups(): Promise<Object>;
/**
* Get session
*/
getSession(): Promise<any>;
/**
* Navigate browser to login page
*/
navigateToLoginPage(): void;
/**
* Navigate browser to redirect page
*/
navigateToRedirectPage(): void;
/**
* Logout current user and clear token
*/
logout(): void;
}