fix: auth
This commit is contained in:
parent
5eb1c2d0ae
commit
1720bee265
3 changed files with 6 additions and 8 deletions
|
@ -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;
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue