44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
|
|
import { apiWrapper, boolApiWrapper } from './index'
|
||
|
|
|
||
|
|
// /**
|
||
|
|
// * Login with salt
|
||
|
|
// * @param username - Username
|
||
|
|
// * @param password - Password
|
||
|
|
// * @returns Token if login successful, undefined otherwise
|
||
|
|
// */
|
||
|
|
// export async function login(username: string, password: string): Promise<string | undefined> {
|
||
|
|
// const salt: string | undefined = await apiWrapper('/api/common/salt', { username });
|
||
|
|
// if (typeof salt === 'undefined') return undefined;
|
||
|
|
|
||
|
|
// const computedPassword = computePasswordWithSalt(password, salt);
|
||
|
|
// return apiWrapper('/api/common/login', { username, password: computedPassword });
|
||
|
|
// }
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Web login
|
||
|
|
* @param username - Username
|
||
|
|
* @param password - Password
|
||
|
|
* @returns Token if login successful, undefined otherwise
|
||
|
|
*/
|
||
|
|
export async function webLogin(username: string, password: string): Promise<string | undefined> {
|
||
|
|
return apiWrapper('/api/common/webLogin', { username, password });
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Logout
|
||
|
|
* @param token - Authentication token
|
||
|
|
* @returns true if logout successful, false otherwise if logout failed
|
||
|
|
*/
|
||
|
|
export async function logout(token: string): Promise<boolean> {
|
||
|
|
return boolApiWrapper('/api/common/logout', { token });
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Validate token
|
||
|
|
* @param token - Authentication token
|
||
|
|
* @returns true if token is valid, false otherwise
|
||
|
|
*/
|
||
|
|
export async function tokenValid(token: string): Promise<boolean> {
|
||
|
|
return boolApiWrapper('/api/common/tokenValid', { token });
|
||
|
|
}
|