diff --git a/src/signup.tsx b/src/signup.tsx
index 9472468..3f72d5f 100644
--- a/src/signup.tsx
+++ b/src/signup.tsx
@@ -6,101 +6,101 @@ import Cookies from 'js-cookie'
import { fetchToken } from "./login";
const signUp = async (username: string, password: string, token: string) => {
- try {
- const response = await api.post(`/signup?token=${token}`, {
- username: username,
- password: password,
- }, {
- });
- return response.data.access_token;
- } catch (error) {
- console.error('Error fetching token:', error);
- throw error;
- }
+ try {
+ const response = await api.post(`/auth/signup?token=${token}`, {
+ username: username,
+ password: password,
+ }, {
+ });
+ return response.data.access_token;
+ } catch (error) {
+ console.error('Error fetching token:', error);
+ throw error;
+ }
};
export function SignupPage(props: {}) {
- const [apiAuthenticated, setApiAuthenticated] = useContext(apiAuthenticatedContext)
- const [searchParam, setSearchParam] = useSearchParams();
- const token = searchParam.get('token');
- if (token === null){
- return
+ const [apiAuthenticated, setApiAuthenticated] = useContext(apiAuthenticatedContext)
+ const [searchParam, setSearchParam] = useSearchParams();
+ const token = searchParam.get('token');
+ if (token === null) {
+ return
+ }
+
+ if (apiAuthenticated) {
+ return
+ }
+
+ const handleSubmit: FormEventHandler = (event: FormEvent) => {
+ event.preventDefault();
+ const data = new FormData(event.currentTarget);
+ const usernameFormData: FormDataEntryValue | null = data.get('username');
+ const passwordFormData: FormDataEntryValue | null = data.get('password');
+ if (usernameFormData === null || passwordFormData === null) {
+ return
}
-
- if (apiAuthenticated) {
- return
- }
-
- const handleSubmit: FormEventHandler = (event: FormEvent) => {
- event.preventDefault();
- const data = new FormData(event.currentTarget);
- const usernameFormData: FormDataEntryValue | null = data.get('username');
- const passwordFormData: FormDataEntryValue | null = data.get('password');
- if (usernameFormData === null || passwordFormData === null){
- return
- }
- const username: string = usernameFormData.toString();
- const password: string = passwordFormData.toString();
+ const username: string = usernameFormData.toString();
+ const password: string = passwordFormData.toString();
- signUp(username, password, token).then(
- () => {
- fetchToken(username, password, true).then(
- (token) => {
- setApiAuthenticated(true)
- },
- (error) => {
- return Promise.reject(error);
- }
- )
- }
+ signUp(username, password, token).then(
+ () => {
+ fetchToken(username, password, true).then(
+ (token) => {
+ setApiAuthenticated(true)
+ },
+ (error) => {
+ return Promise.reject(error);
+ }
)
- }
-
- return (
-
-
-
-
- Sign up
-
-
-
-
-
-
-
-
+ }
)
+ }
+
+ return (
+
+
+
+
+ Sign up
+
+
+
+
+
+
+
+
+ )
}