mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 20:50:07 +00:00
* optimize fm * chore: auto-fix linting and formatting issues * fix: type * chore: auto-fix linting and formatting issues --------- Co-authored-by: uubulb <uubulb@users.noreply.github.com> Co-authored-by: naiba <hi@nai.ba> Co-authored-by: naiba <naiba@users.noreply.github.com>
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { ModelOauth2LoginResponse } from "@/types"
|
|
|
|
import { FetcherMethod, fetcher } from "./api"
|
|
|
|
export enum Oauth2RequestType {
|
|
LOGIN = 1,
|
|
BIND = 2,
|
|
}
|
|
|
|
export const getOauth2RedirectURL = async (
|
|
provider: string,
|
|
rType: Oauth2RequestType,
|
|
): Promise<ModelOauth2LoginResponse> => {
|
|
const sType = "type"
|
|
return fetcher<ModelOauth2LoginResponse>(FetcherMethod.GET, `/api/v1/oauth2/${provider}`, {
|
|
sType: rType,
|
|
})
|
|
}
|
|
|
|
export const bindOauth2 = async (
|
|
provider: string,
|
|
state: string,
|
|
code: string,
|
|
): Promise<ModelOauth2LoginResponse> => {
|
|
return fetcher<ModelOauth2LoginResponse>(
|
|
FetcherMethod.POST,
|
|
`/api/v1/oauth2/${provider}/bind`,
|
|
{
|
|
state: state,
|
|
code: code,
|
|
},
|
|
)
|
|
}
|
|
|
|
export const unbindOauth2 = async (provider: string): Promise<ModelOauth2LoginResponse> => {
|
|
return fetcher<ModelOauth2LoginResponse>(
|
|
FetcherMethod.POST,
|
|
`/api/v1/oauth2/${provider}/unbind`,
|
|
)
|
|
}
|
|
|
|
export const oauth2callback = async (
|
|
provider: string,
|
|
state: string,
|
|
code: string,
|
|
): Promise<void> => {
|
|
return fetcher<void>(FetcherMethod.POST, `/api/v1/oauth2/${provider}/callback`, {
|
|
state,
|
|
code,
|
|
})
|
|
}
|