Skip to content

Commit

Permalink
api修正
Browse files Browse the repository at this point in the history
  • Loading branch information
cateiru committed Feb 14, 2024
1 parent 25c526f commit 3fd5dfc
Show file tree
Hide file tree
Showing 57 changed files with 50 additions and 232 deletions.
4 changes: 1 addition & 3 deletions components/Auth/useOidcRequire.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useRouter, useSearchParams} from 'next/navigation';
import React from 'react';
import {api} from '../../utils/api';
import {api, fetch} from '../../utils/api';
import {
PublicAuthenticationLoginSessionSchema,
PublicAuthenticationRequest,
Expand Down Expand Up @@ -47,8 +47,6 @@ export const useOidcRequire = (submit: () => Promise<void>) => {

try {
res = await fetch(api('/oidc/require'), {
credentials: 'include',
mode: 'cors',
method: 'POST',
body: params,
headers: {
Expand Down
4 changes: 0 additions & 4 deletions components/Auth/useOidcSubmit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export const useOidcSubmit = (): Returns => {
}

const response = await submitRequest({
credentials: 'include',
mode: 'cors',
method: 'POST',
body: params,
headers: {
Expand Down Expand Up @@ -67,8 +65,6 @@ export const useOidcSubmit = (): Returns => {
}

const response = await cancelRequest({
credentials: 'include',
mode: 'cors',
method: 'POST',
body: params,
headers: {
Expand Down
2 changes: 0 additions & 2 deletions components/Client/ClientAllowUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ export const ClientAllowUser = () => {
const res = await request({
method: 'POST',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down
2 changes: 0 additions & 2 deletions components/Client/ClientAllowUserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export const ClientAllowUserTable: React.FC<{id: string | string[]}> = ({
const res = await request(
{
method: 'DELETE',
mode: 'cors',
credentials: 'include',
},
param
);
Expand Down
2 changes: 0 additions & 2 deletions components/Client/ClientDeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export const ClientDeleteModal: React.FC<Props> = ({clientId, orgId}) => {
const res = await request(
{
method: 'DELETE',
mode: 'cors',
credentials: 'include',
},
params
);
Expand Down
8 changes: 0 additions & 8 deletions components/Client/EditClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ export const EditClient = () => {
const c = async () => {
const res = await requestConfig({
method: 'GET',
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand All @@ -113,8 +111,6 @@ export const EditClient = () => {
const res = await request(
{
method: 'GET',
mode: 'cors',
credentials: 'include',
},
param
);
Expand Down Expand Up @@ -206,8 +202,6 @@ export const EditClient = () => {

const res = await request({
method: 'PUT',
mode: 'cors',
credentials: 'include',
body: form,
});

Expand All @@ -231,8 +225,6 @@ export const EditClient = () => {
const res = await requestDeleteImage(
{
method: 'DELETE',
mode: 'cors',
credentials: 'include',
},
param
);
Expand Down
4 changes: 0 additions & 4 deletions components/Client/RegisterClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ export const RegisterClient = () => {
const f = async () => {
const res = await requestConfig({
method: 'GET',
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down Expand Up @@ -141,8 +139,6 @@ export const RegisterClient = () => {

const res = await request({
method: 'POST',
mode: 'cors',
credentials: 'include',
body: form,
});

Expand Down
2 changes: 0 additions & 2 deletions components/Common/Form/OrgJoinUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export const OrgJoinUser: React.FC<Props> = props => {
const res = await request({
method: 'POST',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down
2 changes: 0 additions & 2 deletions components/Common/Form/UserNameForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export const UserNameForm: React.FC<Props> = ({userName}) => {

const res = await request({
method: 'POST',
mode: 'cors',
credentials: 'include',
body: form,
});

Expand Down
2 changes: 0 additions & 2 deletions components/Common/useLogout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export const useLogout = (): Returns => {
const logout = async () => {
const res = await request({
method: 'POST',
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down
6 changes: 3 additions & 3 deletions components/Common/useRequest.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useToast} from '@chakra-ui/react';
import {api} from '../../utils/api';
import {api, fetch} from '../../utils/api';
import {
ErrorSchema,
ErrorType,
Expand All @@ -13,15 +13,15 @@ interface Options {

interface Returns {
request: (
data: RequestInit,
data?: RequestInit,
urlParams?: URLSearchParams
) => Promise<Response | undefined>;
}

export const useRequest = (path: string, options?: Options): Returns => {
const toast = useToast();

const request = async (data: RequestInit, urlParams?: URLSearchParams) => {
const request = async (data?: RequestInit, urlParams?: URLSearchParams) => {
try {
const res = await fetch(api(path, urlParams), data);

Expand Down
2 changes: 0 additions & 2 deletions components/Common/useSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const useSession = () => {

fetch(api('/user/me'), {
method: 'GET',
credentials: 'include',
mode: 'cors',
})
.then(async res => {
if (res.ok) {
Expand Down
2 changes: 0 additions & 2 deletions components/Histories/LogoutDevice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export const LogoutDevice: React.FC<Props> = props => {

const res = await request({
method: 'POST',
mode: 'cors',
credentials: 'include',
body: form,
});

Expand Down
2 changes: 0 additions & 2 deletions components/Login/OtpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export const OtpPage: React.FC<Props> = props => {
const res = await request({
method: 'POST',
body: form,
credentials: 'include',
mode: 'cors',
headers: {
...oauthLoginSession(),
},
Expand Down
2 changes: 0 additions & 2 deletions components/Login/UserIDEmailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export const UserIDEmailForm: React.FC<Props> = ({
const res = await request({
method: 'POST',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down
2 changes: 0 additions & 2 deletions components/Login/UserIDEmailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export const UserIDEmailPage: React.FC<Props> = props => {
const res = await request({
method: 'POST',
body: form,
credentials: 'include',
mode: 'cors',
headers: {
...getOauthLoginSession(),
},
Expand Down
8 changes: 0 additions & 8 deletions components/Login/useWebAuthn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export const useWebAuthn = (loginSuccess: (user: UserMe) => void): Returns => {

const f = async () => {
const res = await getBeginKey({
mode: 'cors',
credentials: 'include',
method: 'POST',
});
if (!res) return;
Expand Down Expand Up @@ -76,8 +74,6 @@ export const useWebAuthn = (loginSuccess: (user: UserMe) => void): Returns => {
}

const resCredential = await pushCredential({
mode: 'cors',
credentials: 'include',
body: JSON.stringify(credential),
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -112,8 +108,6 @@ export const useWebAuthn = (loginSuccess: (user: UserMe) => void): Returns => {

const onClickWebAuthn = async () => {
const res = await getBeginKey({
mode: 'cors',
credentials: 'include',
method: 'POST',
});
if (!res) return;
Expand Down Expand Up @@ -145,8 +139,6 @@ export const useWebAuthn = (loginSuccess: (user: UserMe) => void): Returns => {
}

const resCredential = await pushCredential({
mode: 'cors',
credentials: 'include',
body: JSON.stringify(credential),
headers: {
'Content-Type': 'application/json',
Expand Down
4 changes: 0 additions & 4 deletions components/Organization/JoinOrganization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ const InviteForm: React.FC<InviteFormProps> = ({
const res = await request({
method: 'POST',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down Expand Up @@ -161,8 +159,6 @@ const JoinForm: React.FC<JoinFormProps> = ({
const res = await request({
method: 'POST',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down
6 changes: 0 additions & 6 deletions components/Organization/OrganizationMember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ export const OrganizationMember: React.FC<Props> = ({id}) => {
const res = await request({
method: 'PUT',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand All @@ -132,8 +130,6 @@ export const OrganizationMember: React.FC<Props> = ({id}) => {
const res = await request(
{
method: 'DELETE',
mode: 'cors',
credentials: 'include',
},
param
);
Expand All @@ -154,8 +150,6 @@ export const OrganizationMember: React.FC<Props> = ({id}) => {
const res = await requestJoin(
{
method: 'DELETE',
mode: 'cors',
credentials: 'include',
},
param
);
Expand Down
4 changes: 0 additions & 4 deletions components/Profile/UpdateAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ export const UpdateAvatar = () => {
const res = await request({
method: 'POST',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down Expand Up @@ -150,8 +148,6 @@ export const UpdateAvatar = () => {

const res = await request({
method: 'DELETE',
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down
2 changes: 0 additions & 2 deletions components/Profile/useUpdateProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export const useUpdateProfile = (): Returns => {
const res = await request({
method: 'PUT',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down
2 changes: 0 additions & 2 deletions components/RegisterAccount/EmailInputPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export const EmailInputPage: React.FC<Props> = props => {

const res = await request({
method: 'POST',
credentials: 'include',
mode: 'cors',
body: form,
});

Expand Down
2 changes: 0 additions & 2 deletions components/RegisterAccount/EmailResend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export const EmailResend: React.FC<Props> = props => {

const res = await request({
method: 'POST',
credentials: 'include',
mode: 'cors',
body: form,
headers: {
'X-Register-Token': props.registerToken,
Expand Down
2 changes: 0 additions & 2 deletions components/RegisterAccount/EmailVerifyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export const EmailVerifyPage: React.FC<Props> = props => {

const res = await request({
method: 'POST',
credentials: 'include',
mode: 'cors',
body: form,
headers: {
'X-Register-Token': props.registerToken,
Expand Down
4 changes: 0 additions & 4 deletions components/RegisterAccount/RegisterCertificatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export const RegisterCertificatePage: React.FC<Props> = props => {

const res = await requestPassword({
method: 'POST',
credentials: 'include',
mode: 'cors',
body: form,
headers: {
'X-Register-Token': props.registerToken,
Expand All @@ -59,8 +57,6 @@ export const RegisterCertificatePage: React.FC<Props> = props => {
const onSubmitPasskey = async (data: RegistrationPublicKeyCredential) => {
const res = await requestPasskey({
method: 'POST',
credentials: 'include',
mode: 'cors',
body: JSON.stringify(data),
headers: {
'X-Register-Token': props.registerToken,
Expand Down
2 changes: 0 additions & 2 deletions components/RegisterAccount/RegisterPasskeyForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const RegisterPasskeyForm: React.FC<Props> = props => {
const f = async () => {
const res = await request({
method: 'POST',
credentials: 'include',
mode: 'cors',
headers: {
'X-Register-Token': props.registerToken,
},
Expand Down
2 changes: 0 additions & 2 deletions components/RegisterAccount/useInvite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export const useInvite = (

const res = await request({
method: 'POST',
mode: 'cors',
credentials: 'include',
body: form,
});

Expand Down
2 changes: 0 additions & 2 deletions components/ReregistrationPassword/Forget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export const Forget = () => {
const res = await request({
method: 'POST',
body: form,
mode: 'cors',
credentials: 'include',
});

if (res) {
Expand Down
Loading

0 comments on commit 3fd5dfc

Please sign in to comment.