2022-04-27 18:36:26 +08:00
|
|
|
import api from './api';
|
2022-04-09 12:20:21 +08:00
|
|
|
|
2022-04-12 15:03:38 +08:00
|
|
|
export const invokeSocialSignIn = async (
|
|
|
|
connectorId: string,
|
|
|
|
state: string,
|
|
|
|
redirectUri: string
|
|
|
|
) => {
|
2022-04-09 12:20:21 +08:00
|
|
|
type Response = {
|
|
|
|
redirectTo: string;
|
|
|
|
};
|
|
|
|
|
2022-04-27 18:36:26 +08:00
|
|
|
return api
|
2022-04-09 12:20:21 +08:00
|
|
|
.post('/api/session/sign-in/social', {
|
|
|
|
json: {
|
|
|
|
connectorId,
|
|
|
|
state,
|
|
|
|
redirectUri,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.json<Response>();
|
|
|
|
};
|
|
|
|
|
2022-04-19 16:32:33 +08:00
|
|
|
export const signInWithSocial = async (parameters: {
|
2022-04-09 12:20:21 +08:00
|
|
|
connectorId: string;
|
|
|
|
redirectUri: string;
|
|
|
|
code: string;
|
|
|
|
}) => {
|
|
|
|
type Response = {
|
|
|
|
redirectTo: string;
|
|
|
|
};
|
|
|
|
|
2022-04-27 18:36:26 +08:00
|
|
|
return api
|
2022-05-09 15:17:42 +08:00
|
|
|
.post('/api/session/sign-in/social/auth', {
|
2022-04-09 12:20:21 +08:00
|
|
|
json: parameters,
|
|
|
|
})
|
|
|
|
.json<Response>();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const bindSocialAccount = async (connectorId: string) => {
|
2022-04-27 18:36:26 +08:00
|
|
|
return api
|
2022-05-24 20:48:12 +08:00
|
|
|
.post('/api/session/bind-social', {
|
2022-04-26 14:32:45 +08:00
|
|
|
json: {
|
|
|
|
connectorId,
|
|
|
|
},
|
|
|
|
})
|
2022-05-24 20:48:12 +08:00
|
|
|
.json();
|
2022-04-26 14:32:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const bindSocialRelatedUser = async (connectorId: string) => {
|
|
|
|
type Response = {
|
|
|
|
redirectTo: string;
|
|
|
|
};
|
|
|
|
|
2022-04-27 18:36:26 +08:00
|
|
|
return api
|
2022-04-09 12:20:21 +08:00
|
|
|
.post('/api/session/sign-in/bind-social-related-user', {
|
|
|
|
json: {
|
|
|
|
connectorId,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.json<Response>();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const registerWithSocial = async (connectorId: string) => {
|
|
|
|
type Response = {
|
|
|
|
redirectTo: string;
|
|
|
|
};
|
|
|
|
|
2022-04-27 18:36:26 +08:00
|
|
|
return api
|
2022-04-09 12:20:21 +08:00
|
|
|
.post('/api/session/register/social', {
|
|
|
|
json: {
|
|
|
|
connectorId,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.json<Response>();
|
|
|
|
};
|