fix: auth

This commit is contained in:
hippoz 2021-10-04 23:02:13 +03:00
parent 5eb1c2d0ae
commit 1720bee265
Signed by: hippoz
GPG key ID: 7C52899193467641
3 changed files with 6 additions and 8 deletions

View file

@ -1,7 +1,7 @@
import config from '../config';
import { getToken } from "./tokenManager";
export async function APIRequest(endpoint, options) {
export async function unauthenticated(endpoint, options) {
let res;
let json;
let isOK = false;
@ -59,5 +59,3 @@ export async function authenticated(endpoint, options) {
return { res, json, isOK, err };
};
export default APIRequest;

View file

@ -2,7 +2,7 @@ import { useState } from 'react';
import { useHistory } from 'react-router-dom';
import Notification from '../Notification';
import APIRequest from '../../api/request';
import { unauthenticated } from '../../api/request';
import { getSignupMessageFromError } from '../../common/util/errors'
export default function Create() {
@ -16,7 +16,7 @@ export default function Create() {
const [ info, setInfo ] = useState();
const doCreateAccount = async () => {
const { json, isOK } = await APIRequest('/api/v1/users/account/create', {
const { json, isOK } = await unauthenticated('/api/v1/users/account/create', {
method: 'POST',
headers: {
'Accept': 'application/json',
@ -48,7 +48,7 @@ export default function Create() {
return;
}
const { json, isOK } = await APIRequest('/api/v1/users/account/create/info', {
const { json, isOK } = await unauthenticated('/api/v1/users/account/create/info', {
method: 'GET',
headers: {
'Accept': 'application/json',

View file

@ -2,7 +2,7 @@ import { useState } from 'react';
import { useHistory } from 'react-router-dom';
import Notification from '../Notification';
import APIRequest from '../../api/request';
import { unauthenticated } from '../../api/request';
import { login } from '../../api/authenticator';
import { setToken } from "../../api/tokenManager";
import { getLoginMessageFromError } from '../../common/util/errors'
@ -21,7 +21,7 @@ export default function Login() {
return;
}
const { json, isOK } = await APIRequest('/api/v1/users/token/create', {
const { json, isOK } = await unauthenticated('/api/v1/users/token/create', {
method: 'POST',
headers: {
'Accept': 'application/json',