2019-11-19 06:37:36 +07:00
|
|
|
import { FirstFactorPath } from "./Api";
|
|
|
|
import { PostWithOptionalResponse } from "./Client";
|
|
|
|
import { SignInResponse } from "./SignIn";
|
|
|
|
|
|
|
|
interface PostFirstFactorBody {
|
|
|
|
username: string;
|
|
|
|
password: string;
|
|
|
|
keepMeLoggedIn: boolean;
|
|
|
|
targetURL?: string;
|
2021-03-05 11:18:31 +07:00
|
|
|
requestMethod?: string;
|
2019-11-19 06:37:36 +07:00
|
|
|
}
|
|
|
|
|
2021-03-05 11:18:31 +07:00
|
|
|
export async function postFirstFactor(
|
|
|
|
username: string,
|
|
|
|
password: string,
|
|
|
|
rememberMe: boolean,
|
|
|
|
targetURL?: string,
|
|
|
|
requestMethod?: string,
|
|
|
|
) {
|
2019-11-19 06:37:36 +07:00
|
|
|
const data: PostFirstFactorBody = {
|
2021-01-02 17:58:24 +07:00
|
|
|
username,
|
|
|
|
password,
|
|
|
|
keepMeLoggedIn: rememberMe,
|
2019-11-19 06:37:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
if (targetURL) {
|
|
|
|
data.targetURL = targetURL;
|
|
|
|
}
|
2021-03-05 11:18:31 +07:00
|
|
|
|
|
|
|
if (requestMethod) {
|
|
|
|
data.requestMethod = requestMethod;
|
|
|
|
}
|
|
|
|
|
2019-11-19 06:37:36 +07:00
|
|
|
const res = await PostWithOptionalResponse<SignInResponse>(FirstFactorPath, data);
|
2021-01-02 17:58:24 +07:00
|
|
|
return res ? res : ({} as SignInResponse);
|
|
|
|
}
|