mirror of
https://github.com/Dan6erbond/sk-auth.git
synced 2025-04-23 01:16:26 +02:00
27 lines
732 B
JavaScript
27 lines
732 B
JavaScript
async function signIn(provider, data, config) {
|
|
if (data) {
|
|
const path2 = mergePath(["/api/auth", config?.basePath ?? null], `/callback/${provider}`);
|
|
const res = await fetch(path2, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify(data)
|
|
});
|
|
return await res.json();
|
|
}
|
|
let redirectUrl;
|
|
if (config?.redirectUrl) {
|
|
redirectUrl = config.redirectUrl;
|
|
}
|
|
const queryData = {
|
|
redirect: redirectUrl ?? "/"
|
|
};
|
|
const query = new URLSearchParams(queryData);
|
|
const path = mergePath(["/api/auth", config?.basePath ?? null], `/signin/${provider}?${query}`);
|
|
return path;
|
|
}
|
|
|
|
export { signIn };
|
|
//# sourceMappingURL=signIn.esm.js.map
|