0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

refactor(ui): update api lang header (#680)

update api lang header
This commit is contained in:
simeng-li 2022-04-27 18:36:26 +08:00 committed by GitHub
parent 7278ba4095
commit 6e5f14792e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 22 deletions

View file

@ -0,0 +1,12 @@
import i18next from 'i18next';
import ky from 'ky';
export default ky.extend({
hooks: {
beforeRequest: [
(request) => {
request.headers.set('Accept-Language', i18next.language);
},
],
},
});

View file

@ -1,9 +1,9 @@
import ky from 'ky';
import api from './api';
export const consent = async () => {
type Response = {
redirectTo: string;
};
return ky.post('/api/session/consent').json<Response>();
return api.post('/api/session/consent').json<Response>();
};

View file

@ -1,11 +1,11 @@
import ky from 'ky';
import api from './api';
export const register = async (username: string, password: string) => {
type Response = {
redirectTo: string;
};
return ky
return api
.post('/api/session/register/username-password', {
json: {
username,
@ -16,7 +16,7 @@ export const register = async (username: string, password: string) => {
};
export const sendRegisterSmsPasscode = async (phone: string) => {
return ky
return api
.post('/api/session/register/passwordless/sms/send-passcode', {
json: {
phone,
@ -30,7 +30,7 @@ export const verifyRegisterSmsPasscode = async (phone: string, passcode: string)
redirectTo: string;
};
return ky
return api
.post('/api/session/register/passwordless/sms/verify-passcode', {
json: {
phone,
@ -41,7 +41,7 @@ export const verifyRegisterSmsPasscode = async (phone: string, passcode: string)
};
export const sendRegisterEmailPasscode = async (email: string) => {
return ky
return api
.post('/api/session/register/passwordless/email/send-passcode', {
json: {
email,
@ -55,7 +55,7 @@ export const verifyRegisterEmailPasscode = async (email: string, passcode: strin
redirectTo: string;
};
return ky
return api
.post('/api/session/register/passwordless/email/verify-passcode', {
json: {
email,

View file

@ -1,6 +1,6 @@
/**
* Used to get and general sign-in experience settings.
* The API will be depreated in the future once SSR is implemented.
* The API will be deprecated in the future once SSR is implemented.
*/
import { SignInExperience } from '@logto/schemas';

View file

@ -1,5 +1,4 @@
import ky from 'ky';
import api from './api';
import { bindSocialAccount } from './social';
export const signInBasic = async (username: string, password: string, socialToBind?: string) => {
@ -7,7 +6,7 @@ export const signInBasic = async (username: string, password: string, socialToBi
redirectTo: string;
};
const result = await ky
const result = await api
.post('/api/session/sign-in/username-password', {
json: {
username,
@ -24,7 +23,7 @@ export const signInBasic = async (username: string, password: string, socialToBi
};
export const sendSignInSmsPasscode = async (phone: string) => {
return ky
return api
.post('/api/session/sign-in/passwordless/sms/send-passcode', {
json: {
phone,
@ -42,7 +41,7 @@ export const verifySignInSmsPasscode = async (
redirectTo: string;
};
const result = await ky
const result = await api
.post('/api/session/sign-in/passwordless/sms/verify-passcode', {
json: {
phone,
@ -59,7 +58,7 @@ export const verifySignInSmsPasscode = async (
};
export const sendSignInEmailPasscode = async (email: string) => {
return ky
return api
.post('/api/session/sign-in/passwordless/email/send-passcode', {
json: {
email,
@ -77,7 +76,7 @@ export const verifySignInEmailPasscode = async (
redirectTo: string;
};
const result = await ky
const result = await api
.post('/api/session/sign-in/passwordless/email/verify-passcode', {
json: {
email,

View file

@ -1,4 +1,4 @@
import ky from 'ky';
import api from './api';
export const invokeSocialSignIn = async (
connectorId: string,
@ -9,7 +9,7 @@ export const invokeSocialSignIn = async (
redirectTo: string;
};
return ky
return api
.post('/api/session/sign-in/social', {
json: {
connectorId,
@ -30,7 +30,7 @@ export const signInWithSocial = async (parameters: {
redirectTo: string;
};
return ky
return api
.post('/api/session/sign-in/social', {
json: parameters,
})
@ -42,7 +42,7 @@ export const bindSocialAccount = async (connectorId: string) => {
redirectTo: string;
};
return ky
return api
.post('/api/session/sign-in/bind-social', {
json: {
connectorId,
@ -56,7 +56,7 @@ export const bindSocialRelatedUser = async (connectorId: string) => {
redirectTo: string;
};
return ky
return api
.post('/api/session/sign-in/bind-social-related-user', {
json: {
connectorId,
@ -70,7 +70,7 @@ export const registerWithSocial = async (connectorId: string) => {
redirectTo: string;
};
return ky
return api
.post('/api/session/register/social', {
json: {
connectorId,