import { RSA } from "@/utils/crypto";
import {get, post, Result} from "../base";

/**
 * 用户登录换取token
 * @param username 用户名
 * @param password 密码
 */
export function login(username: string, password: string, google: string) {
  return post<any, Result<any>>("/auth/login", {
    username: username,
    google: google,
    password: RSA.encrypt(password)
  });
}

/**
 *  是否有谷歌验证器
 *
 * @returns .
 */
export function hasGoogleOtp() {
  return get<any, Result<any>>("/auth/hasGoogleOtp", {});
}
/**
 *  验证谷歌验证器
 *
 * @returns .
 */
export function createGoogleOtp() {
  return get<any, Result<any>>("/auth/googleOtp/create", {});
}
/**
 *  验证谷歌验证器
 *
 * @returns .
 */
export function save(data: any) {
  return post<any, Result<any>>("/auth/googleOtp/save", data);
}
/**
 *  登出
 *
 * @returns .
 */
export function logout() {
  return post<any, Result<any>>("/auth/logout", {});
}
