diff --git a/frontend/components/RouteGuard.js b/frontend/components/RouteGuard.js
index 71bfd2562..3a7b89ec6 100644
--- a/frontend/components/RouteGuard.js
+++ b/frontend/components/RouteGuard.js
@@ -1,85 +1,85 @@
-import { useEffect,useState } from "react";
+import { useEffect, useState } from "react";
import Image from "next/image";
import { useRouter } from "next/router";
import checkAuth from "~/pages/api/auth/CheckAuth";
-import { publicPaths } from "../const";
+import { publicPaths } from "~/const";
// #TODO: finish spinner only when the data loads fully
// #TODO: Redirect somewhere if the page does not exist
export default function RouteGuard({ children }) {
- const router = useRouter();
- const [authorized, setAuthorized] = useState(false);
+ const router = useRouter();
+ const [authorized, setAuthorized] = useState(false);
- useEffect(() => {
- // on initial load - run auth check
- (async () => {
- await authCheck(router.asPath);
- })();
+ useEffect(() => {
+ // on initial load - run auth check
+ (async () => {
+ await authCheck(router.asPath);
+ })();
- // on route change start - hide page content by setting authorized to false
- // #TODO: add the loading page when not yet authorized.
- const hideContent = () => setAuthorized(false);
- // const onError = () => setAuthorized(true)
- router.events.on("routeChangeStart", hideContent);
- // router.events.on("routeChangeError", onError);
+ // on route change start - hide page content by setting authorized to false
+ // #TODO: add the loading page when not yet authorized.
+ const hideContent = () => setAuthorized(false);
+ // const onError = () => setAuthorized(true)
+ router.events.on("routeChangeStart", hideContent);
+ // router.events.on("routeChangeError", onError);
- // on route change complete - run auth check
- router.events.on("routeChangeComplete", authCheck);
+ // on route change complete - run auth check
+ router.events.on("routeChangeComplete", authCheck);
- // unsubscribe from events in useEffect return function
- return () => {
- router.events.off("routeChangeStart", hideContent);
- router.events.off("routeChangeComplete", authCheck);
- // router.events.off("routeChangeError", onError);
- };
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
+ // unsubscribe from events in useEffect return function
+ return () => {
+ router.events.off("routeChangeStart", hideContent);
+ router.events.off("routeChangeComplete", authCheck);
+ // router.events.off("routeChangeError", onError);
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
- /**
- * redirect to login page if accessing a private page and not logged in
- * @param {*} url - the url of the page we are trying to go to
- */
- async function authCheck(url) {
- // Make sure that we don't redirect when the user is on the following pages.
- const path = "/" + url.split("?")[0].split("/")[1];
+ /**
+ * redirect to login page if accessing a private page and not logged in
+ * @param {*} url - the url of the page we are trying to go to
+ */
+ async function authCheck(url) {
+ // Make sure that we don't redirect when the user is on the following pages.
+ const path = "/" + url.split("?")[0].split("/")[1];
- // Check if the user is authenticated
- const response = await checkAuth();
- // #TODO: figure our why sometimes it doesn't output a response
- if (!publicPaths.includes(path)) {
- try {
- if (response.status !== 200) {
- router.push("/login");
- console.log("Unauthorized to access.");
- setAuthorized(false);
- } else {
- setAuthorized(true);
- console.log("Authorized to access.");
- }
- } catch (error) {
- console.log(
- "Error (probably the authCheck route is stuck again...):",
- error
- );
- }
- }
- }
+ // Check if the user is authenticated
+ const response = await checkAuth();
+ // #TODO: figure our why sometimes it doesn't output a response
+ if (!publicPaths.includes(path)) {
+ try {
+ if (response.status !== 200) {
+ router.push("/login");
+ console.log("Unauthorized to access.");
+ setAuthorized(false);
+ } else {
+ setAuthorized(true);
+ console.log("Authorized to access.");
+ }
+ } catch (error) {
+ console.log(
+ "Error (probably the authCheck route is stuck again...):",
+ error
+ );
+ }
+ }
+ }
- if (authorized) {
- return children;
- } else {
- return (
-
-
-
- );
- }
+ if (authorized) {
+ return children;
+ } else {
+ return (
+
+
+
+ );
+ }
}
diff --git a/frontend/components/utilities/SecurityClient.js b/frontend/components/utilities/SecurityClient.js
index 783b44633..587b43517 100644
--- a/frontend/components/utilities/SecurityClient.js
+++ b/frontend/components/utilities/SecurityClient.js
@@ -1,28 +1,28 @@
import token from "~/pages/api/auth/Token";
-import { PATH } from "../../const";
+import { PATH } from "~/const";
export default class SecurityClient {
- static authOrigins = [PATH];
- static #token = "";
+ static authOrigins = [PATH];
+ static #token = "";
- contructor() {}
+ contructor() {}
- static setToken(token) {
- this.#token = token;
- }
+ static setToken(token) {
+ this.#token = token;
+ }
- static async fetchCall(resource, options) {
- let req = new Request(resource, options);
- const destOrigin = new URL(req.url).origin;
+ static async fetchCall(resource, options) {
+ let req = new Request(resource, options);
+ const destOrigin = new URL(req.url).origin;
- if (this.#token == "") {
- this.setToken(await token());
- }
+ if (this.#token == "") {
+ this.setToken(await token());
+ }
- if (this.#token && this.authOrigins.includes(destOrigin)) {
- req.headers.set("Authorization", "Bearer " + this.#token);
- return fetch(req);
- }
- }
+ if (this.#token && this.authOrigins.includes(destOrigin)) {
+ req.headers.set("Authorization", "Bearer " + this.#token);
+ return fetch(req);
+ }
+ }
}
diff --git a/frontend/jsconfig.json b/frontend/jsconfig.json
index 6f859d11a..19a4b9b7a 100644
--- a/frontend/jsconfig.json
+++ b/frontend/jsconfig.json
@@ -8,6 +8,9 @@
"~/utilities/*": [
"components/utilities/*"
],
+ "~/*": [
+ "const"
+ ],
"~/pages/*": [
"pages/*"
],
diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js
index 838d407b9..ff8c2b7e3 100644
--- a/frontend/pages/_app.js
+++ b/frontend/pages/_app.js
@@ -7,7 +7,7 @@ import Layout from "~/components/basic/layout";
import RouteGuard from "~/components/RouteGuard";
import { ENV } from "~/utilities/config";
-import { publicPaths } from "../const.js";
+import { publicPaths } from "~/const";
import "@fortawesome/fontawesome-svg-core/styles.css";
import "../styles/globals.css";
@@ -15,49 +15,49 @@ import "../styles/globals.css";
config.autoAddCss = false;
const App = ({ Component, pageProps, ...appProps }) => {
- const router = useRouter();
- const posthog = initPostHog();
+ const router = useRouter();
+ const posthog = initPostHog();
- useEffect(() => {
- // Init for auto capturing
- const posthog = initPostHog();
+ useEffect(() => {
+ // Init for auto capturing
+ const posthog = initPostHog();
- const handleRouteChange = () => {
- if (typeof window !== "undefined") {
- if (ENV == "production") {
- posthog.capture("$pageview");
- }
- }
- };
+ const handleRouteChange = () => {
+ if (typeof window !== "undefined") {
+ if (ENV == "production") {
+ posthog.capture("$pageview");
+ }
+ }
+ };
- router.events.on("routeChangeComplete", handleRouteChange);
+ router.events.on("routeChangeComplete", handleRouteChange);
- return () => {
- router.events.off("routeChangeComplete", handleRouteChange);
- };
- }, [router.events]);
+ return () => {
+ router.events.off("routeChangeComplete", handleRouteChange);
+ };
+ }, [router.events]);
- // If it's one of these routes, don't add the layout (e.g., these routes are external)
- if (
- publicPaths.includes("/" + appProps.router.pathname.split("/")[1]) ||
- !Component.requireAuth
- ) {
- return ;
- }
+ // If it's one of these routes, don't add the layout (e.g., these routes are external)
+ if (
+ publicPaths.includes("/" + appProps.router.pathname.split("/")[1]) ||
+ !Component.requireAuth
+ ) {
+ return ;
+ }
- return (
-
-
-
-
-
- );
+ return (
+
+
+
+
+
+ );
};
export default App;
{
- /*
diff --git a/frontend/pages/api/auth/ChangePassword2.js b/frontend/pages/api/auth/ChangePassword2.js
index a60a9dd92..d039cc9c9 100644
--- a/frontend/pages/api/auth/ChangePassword2.js
+++ b/frontend/pages/api/auth/ChangePassword2.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This is the second step of the change password process (pake)
@@ -8,33 +8,33 @@ import { PATH } from "../../../const";
* @returns
*/
const changePassword2 = ({
- encryptedPrivateKey,
- iv,
- tag,
- salt,
- verifier,
- clientProof,
+ encryptedPrivateKey,
+ iv,
+ tag,
+ salt,
+ verifier,
+ clientProof,
}) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/password/change-password", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- clientProof: clientProof,
- encryptedPrivateKey: encryptedPrivateKey,
- iv: iv,
- tag: tag,
- salt: salt,
- verifier: verifier,
- }),
- }).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to change the password");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/password/change-password", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ clientProof: clientProof,
+ encryptedPrivateKey: encryptedPrivateKey,
+ iv: iv,
+ tag: tag,
+ salt: salt,
+ verifier: verifier,
+ }),
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to change the password");
+ }
+ });
};
export default changePassword2;
diff --git a/frontend/pages/api/auth/CheckAuth.js b/frontend/pages/api/auth/CheckAuth.js
index fef7ba9d1..d70180d68 100644
--- a/frontend/pages/api/auth/CheckAuth.js
+++ b/frontend/pages/api/auth/CheckAuth.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient.js";
-import { PATH } from "../../../const.js";
+import { PATH } from "~/const";
/**
* This function is used to check if the user is authenticated.
@@ -10,18 +10,18 @@ import { PATH } from "../../../const.js";
* @returns
*/
const checkAuth = async (req, res) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/auth/checkAuth", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- }).then((res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Not authorized");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/auth/checkAuth", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then((res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Not authorized");
+ }
+ });
};
export default checkAuth;
diff --git a/frontend/pages/api/auth/CheckEmailVerificationCode.js b/frontend/pages/api/auth/CheckEmailVerificationCode.js
index 085953346..aaf9205b6 100644
--- a/frontend/pages/api/auth/CheckEmailVerificationCode.js
+++ b/frontend/pages/api/auth/CheckEmailVerificationCode.js
@@ -1,4 +1,4 @@
-import { PATH } from "../../../const.js";
+import { PATH } from "~/const";
/**
* This route check the verification code from the email that user just recieved
@@ -7,16 +7,16 @@ import { PATH } from "../../../const.js";
* @returns
*/
const checkEmailVerificationCode = (email, code) => {
- return fetch(PATH + "/api/v1/signup/email/verify", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email: email,
- code: code,
- }),
- });
+ return fetch(PATH + "/api/v1/signup/email/verify", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ email: email,
+ code: code,
+ }),
+ });
};
export default checkEmailVerificationCode;
diff --git a/frontend/pages/api/auth/CompleteAccountInformationSignup.js b/frontend/pages/api/auth/CompleteAccountInformationSignup.js
index d131ce49f..b315510e5 100644
--- a/frontend/pages/api/auth/CompleteAccountInformationSignup.js
+++ b/frontend/pages/api/auth/CompleteAccountInformationSignup.js
@@ -1,4 +1,4 @@
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This function is called in the end of the signup process.
@@ -16,37 +16,37 @@ import { PATH } from "../../../const";
* @returns
*/
const completeAccountInformationSignup = ({
- email,
- firstName,
- lastName,
- organizationName,
- publicKey,
- ciphertext,
- iv,
- tag,
- salt,
- verifier,
- token
+ email,
+ firstName,
+ lastName,
+ organizationName,
+ publicKey,
+ ciphertext,
+ iv,
+ tag,
+ salt,
+ verifier,
+ token,
}) => {
- return fetch(PATH + "/api/v1/signup/complete-account/signup", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- "Authorization": "Bearer " + token,
- },
- body: JSON.stringify({
- email,
- firstName,
- lastName,
- publicKey,
- encryptedPrivateKey: ciphertext,
- organizationName,
- iv,
- tag,
- salt,
- verifier,
- }),
- });
+ return fetch(PATH + "/api/v1/signup/complete-account/signup", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: "Bearer " + token,
+ },
+ body: JSON.stringify({
+ email,
+ firstName,
+ lastName,
+ publicKey,
+ encryptedPrivateKey: ciphertext,
+ organizationName,
+ iv,
+ tag,
+ salt,
+ verifier,
+ }),
+ });
};
export default completeAccountInformationSignup;
diff --git a/frontend/pages/api/auth/CompleteAccountInformationSignupInvite.js b/frontend/pages/api/auth/CompleteAccountInformationSignupInvite.js
index 3c8a03a0c..4af4381bd 100644
--- a/frontend/pages/api/auth/CompleteAccountInformationSignupInvite.js
+++ b/frontend/pages/api/auth/CompleteAccountInformationSignupInvite.js
@@ -1,4 +1,4 @@
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This function is called in the end of the signup process.
@@ -15,35 +15,35 @@ import { PATH } from "../../../const";
* @returns
*/
const completeAccountInformationSignupInvite = ({
- email,
- firstName,
- lastName,
- publicKey,
- ciphertext,
- iv,
- tag,
- salt,
- verifier,
- token
+ email,
+ firstName,
+ lastName,
+ publicKey,
+ ciphertext,
+ iv,
+ tag,
+ salt,
+ verifier,
+ token,
}) => {
- return fetch(PATH + "/api/v1/signup/complete-account/invite", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- "Authorization": "Bearer " + token,
- },
- body: JSON.stringify({
- email: email,
- firstName: firstName,
- lastName: lastName,
- publicKey: publicKey,
- encryptedPrivateKey: ciphertext,
- iv: iv,
- tag: tag,
- salt: salt,
- verifier: verifier
- }),
- });
+ return fetch(PATH + "/api/v1/signup/complete-account/invite", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: "Bearer " + token,
+ },
+ body: JSON.stringify({
+ email: email,
+ firstName: firstName,
+ lastName: lastName,
+ publicKey: publicKey,
+ encryptedPrivateKey: ciphertext,
+ iv: iv,
+ tag: tag,
+ salt: salt,
+ verifier: verifier,
+ }),
+ });
};
export default completeAccountInformationSignupInvite;
diff --git a/frontend/pages/api/auth/IssueBackupPrivateKey.js b/frontend/pages/api/auth/IssueBackupPrivateKey.js
index b644064a9..ee5e1188d 100644
--- a/frontend/pages/api/auth/IssueBackupPrivateKey.js
+++ b/frontend/pages/api/auth/IssueBackupPrivateKey.js
@@ -1,42 +1,42 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This is the route that issues a backup private key that will afterwards be added into a pdf
*/
const issueBackupPrivateKey = ({
- encryptedPrivateKey,
- iv,
- tag,
- salt,
- verifier,
- clientProof,
+ encryptedPrivateKey,
+ iv,
+ tag,
+ salt,
+ verifier,
+ clientProof,
}) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/password/backup-private-key",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- clientProof: clientProof,
- encryptedPrivateKey: encryptedPrivateKey,
- iv: iv,
- tag: tag,
- salt: salt,
- verifier: verifier,
- }),
- }
- ).then((res) => {
- if (res.status == 200) {
- return res;
- } else {
- return res;
- console.log("Failed to issue the backup key");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/password/backup-private-key",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ clientProof: clientProof,
+ encryptedPrivateKey: encryptedPrivateKey,
+ iv: iv,
+ tag: tag,
+ salt: salt,
+ verifier: verifier,
+ }),
+ }
+ ).then((res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ return res;
+ console.log("Failed to issue the backup key");
+ }
+ });
};
export default issueBackupPrivateKey;
diff --git a/frontend/pages/api/auth/Login1.js b/frontend/pages/api/auth/Login1.js
index 17b878420..697933812 100644
--- a/frontend/pages/api/auth/Login1.js
+++ b/frontend/pages/api/auth/Login1.js
@@ -1,4 +1,4 @@
-import { PATH } from "../../../const.js";
+import { PATH } from "~/const";
/**
* This is the first step of the login process (pake)
@@ -7,16 +7,16 @@ import { PATH } from "../../../const.js";
* @returns
*/
const login1 = (email, clientPublicKey) => {
- return fetch(PATH + "/api/v1/auth/login1", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email: email,
- clientPublicKey,
- }),
- });
+ return fetch(PATH + "/api/v1/auth/login1", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ email: email,
+ clientPublicKey,
+ }),
+ });
};
export default login1;
diff --git a/frontend/pages/api/auth/Login2.js b/frontend/pages/api/auth/Login2.js
index f63a06163..fdb48342e 100644
--- a/frontend/pages/api/auth/Login2.js
+++ b/frontend/pages/api/auth/Login2.js
@@ -1,4 +1,4 @@
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This is the second step of the login process
@@ -7,25 +7,24 @@ import { PATH } from "../../../const";
* @returns
*/
const login2 = (email, clientProof) => {
- return fetch(PATH + "/api/v1/auth/login2", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email: email,
- clientProof,
- }),
- credentials: "include"
- })
- .then(res => {
- if (res.status == 200) {
- console.log("User logged in", res);
- return res;
- } else {
- console.log("Failed to log in");
- }
- })
+ return fetch(PATH + "/api/v1/auth/login2", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ email: email,
+ clientProof,
+ }),
+ credentials: "include",
+ }).then((res) => {
+ if (res.status == 200) {
+ console.log("User logged in", res);
+ return res;
+ } else {
+ console.log("Failed to log in");
+ }
+ });
};
export default login2;
diff --git a/frontend/pages/api/auth/Logout.js b/frontend/pages/api/auth/Logout.js
index 063c57709..4ecfda425 100644
--- a/frontend/pages/api/auth/Logout.js
+++ b/frontend/pages/api/auth/Logout.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route logs the user out. Note: the user should authorized to do this.
@@ -10,27 +10,27 @@ import { PATH } from "../../../const";
* @returns
*/
const logout = async (req, res) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/auth/logout", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- credentials: "include",
- }).then((res) => {
- if (res.status == 200) {
- SecurityClient.setToken("");
- // Delete the cookie by not setting a value; Alternatively clear the local storage
- localStorage.setItem("publicKey", "");
- localStorage.setItem("encryptedPrivateKey", "");
- localStorage.setItem("iv", "");
- localStorage.setItem("tag", "");
- localStorage.setItem("PRIVATE_KEY", "");
- console.log("User logged out", res);
- return res;
- } else {
- console.log("Failed to log out");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/auth/logout", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ credentials: "include",
+ }).then((res) => {
+ if (res.status == 200) {
+ SecurityClient.setToken("");
+ // Delete the cookie by not setting a value; Alternatively clear the local storage
+ localStorage.setItem("publicKey", "");
+ localStorage.setItem("encryptedPrivateKey", "");
+ localStorage.setItem("iv", "");
+ localStorage.setItem("tag", "");
+ localStorage.setItem("PRIVATE_KEY", "");
+ console.log("User logged out", res);
+ return res;
+ } else {
+ console.log("Failed to log out");
+ }
+ });
};
export default logout;
diff --git a/frontend/pages/api/auth/SRP1.js b/frontend/pages/api/auth/SRP1.js
index 838fc096d..04bdec523 100644
--- a/frontend/pages/api/auth/SRP1.js
+++ b/frontend/pages/api/auth/SRP1.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This is the first step of the change password process (pake)
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const SRP1 = ({ clientPublicKey }) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/password/srp1", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- clientPublicKey,
- }),
- }).then(async (res) => {
- if (res.status == 200) {
- return await res.json();
- } else {
- console.log("Failed to do the first step of SRP");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/password/srp1", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ clientPublicKey,
+ }),
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return await res.json();
+ } else {
+ console.log("Failed to do the first step of SRP");
+ }
+ });
};
export default SRP1;
diff --git a/frontend/pages/api/auth/SendVerificationEmail.js b/frontend/pages/api/auth/SendVerificationEmail.js
index 3a35a4fc9..981c55936 100644
--- a/frontend/pages/api/auth/SendVerificationEmail.js
+++ b/frontend/pages/api/auth/SendVerificationEmail.js
@@ -1,19 +1,19 @@
-import { PATH } from "../../../const.js";
+import { PATH } from "~/const";
/**
* This route send the verification email to the user's email (contains a 6-digit verification code)
* @param {*} email
*/
const sendVerificationEmail = (email) => {
- fetch(PATH + "/api/v1/signup/email/signup", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email: email,
- }),
- });
+ fetch(PATH + "/api/v1/signup/email/signup", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ email: email,
+ }),
+ });
};
export default sendVerificationEmail;
diff --git a/frontend/pages/api/auth/Token.js b/frontend/pages/api/auth/Token.js
index 4f1d8ae14..29164aec3 100644
--- a/frontend/pages/api/auth/Token.js
+++ b/frontend/pages/api/auth/Token.js
@@ -1,20 +1,19 @@
-import { PATH } from "../../../const.js";
+import { PATH } from "~/const";
const token = async (req, res) => {
- return fetch(PATH + "/api/v1/auth/token", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- credentials: "include"
- })
- .then(async res => {
- if (res.status == 200) {
- return (await res.json()).token;
- } else {
- console.log('Getting a new token failed');
- }
- })
+ return fetch(PATH + "/api/v1/auth/token", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ credentials: "include",
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).token;
+ } else {
+ console.log("Getting a new token failed");
+ }
+ });
};
export default token;
diff --git a/frontend/pages/api/auth/VerifySignupInvite.js b/frontend/pages/api/auth/VerifySignupInvite.js
index 8f3fed450..19fe229f9 100644
--- a/frontend/pages/api/auth/VerifySignupInvite.js
+++ b/frontend/pages/api/auth/VerifySignupInvite.js
@@ -1,4 +1,4 @@
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route verifies the signup invite link
@@ -6,17 +6,17 @@ import { PATH } from "../../../const";
* @param {*} code
* @returns
*/
-const verifySignupInvite = ({email, code}) => {
- return fetch(PATH + "/api/v1/invite-org/verify", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email,
- code,
- }),
- });
+const verifySignupInvite = ({ email, code }) => {
+ return fetch(PATH + "/api/v1/invite-org/verify", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ email,
+ code,
+ }),
+ });
};
export default verifySignupInvite;
diff --git a/frontend/pages/api/auth/publicKeyInfisical.js b/frontend/pages/api/auth/publicKeyInfisical.js
index 1aaf2664b..070096fb4 100644
--- a/frontend/pages/api/auth/publicKeyInfisical.js
+++ b/frontend/pages/api/auth/publicKeyInfisical.js
@@ -1,4 +1,4 @@
-import { PATH } from "../../../const.js";
+import { PATH } from "~/const";
/**
* This route lets us get the public key of infisical. Th euser doesn't have to be authenticated since this is just the public key.
@@ -7,12 +7,12 @@ import { PATH } from "../../../const.js";
* @returns
*/
const publicKeyInfisical = (req, res) => {
- return fetch(PATH + "/api/v1/key/publicKey/infisical", {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- });
+ return fetch(PATH + "/api/v1/key/publicKey/infisical", {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
};
export default publicKeyInfisical;
diff --git a/frontend/pages/api/files/GetSecrets.js b/frontend/pages/api/files/GetSecrets.js
index e02460900..0924b2fad 100644
--- a/frontend/pages/api/files/GetSecrets.js
+++ b/frontend/pages/api/files/GetSecrets.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient.js";
-import { PATH } from "../../../const.js";
+import { PATH } from "~/const";
/**
* This function fetches the encrypted secrets from the .env file
@@ -9,28 +9,28 @@ import { PATH } from "../../../const.js";
* @returns
*/
const getSecrets = async (workspaceId, env) => {
- return SecurityClient.fetchCall(
- PATH +
- "/api/v1/secret/" +
- workspaceId +
- "?" +
- new URLSearchParams({
- environment: env,
- channel: "web",
- }),
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return await res.json();
- } else {
- console.log("Failed to get project secrets");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH +
+ "/api/v1/secret/" +
+ workspaceId +
+ "?" +
+ new URLSearchParams({
+ environment: env,
+ channel: "web",
+ }),
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return await res.json();
+ } else {
+ console.log("Failed to get project secrets");
+ }
+ });
};
export default getSecrets;
diff --git a/frontend/pages/api/files/UploadSecrets.js b/frontend/pages/api/files/UploadSecrets.js
index 6497a5e1e..93661057d 100644
--- a/frontend/pages/api/files/UploadSecrets.js
+++ b/frontend/pages/api/files/UploadSecrets.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This function uploads the encrypted .env file
@@ -9,24 +9,24 @@ import { PATH } from "../../../const";
* @returns
*/
const uploadSecrets = async ({ workspaceId, secrets, keys, environment }) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/secret/" + workspaceId, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- secrets,
- keys,
- environment,
- channel: "web",
- }),
- }).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to push secrets");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/secret/" + workspaceId, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ secrets,
+ keys,
+ environment,
+ channel: "web",
+ }),
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to push secrets");
+ }
+ });
};
export default uploadSecrets;
diff --git a/frontend/pages/api/integrations/ChangeHerokuConfigVars.js b/frontend/pages/api/integrations/ChangeHerokuConfigVars.js
index 398a417a3..2d09d1780 100644
--- a/frontend/pages/api/integrations/ChangeHerokuConfigVars.js
+++ b/frontend/pages/api/integrations/ChangeHerokuConfigVars.js
@@ -1,27 +1,27 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
const changeHerokuConfigVars = ({ integrationId, key, secrets }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/integration/" + integrationId + "/sync",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- key,
- secrets,
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to sync secrets to Heroku");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/integration/" + integrationId + "/sync",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ key,
+ secrets,
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to sync secrets to Heroku");
+ }
+ });
};
export default changeHerokuConfigVars;
diff --git a/frontend/pages/api/integrations/DeleteIntegration.js b/frontend/pages/api/integrations/DeleteIntegration.js
index 2c58cdfe7..75d1417a7 100644
--- a/frontend/pages/api/integrations/DeleteIntegration.js
+++ b/frontend/pages/api/integrations/DeleteIntegration.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route deletes an integration from a certain project
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const deleteIntegration = ({ integrationId }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/integration/" + integrationId,
- {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).workspace;
- } else {
- console.log("Failed to delete an integration");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/integration/" + integrationId,
+ {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).workspace;
+ } else {
+ console.log("Failed to delete an integration");
+ }
+ });
};
export default deleteIntegration;
diff --git a/frontend/pages/api/integrations/DeleteIntegrationAuth.js b/frontend/pages/api/integrations/DeleteIntegrationAuth.js
index ac38c2ab7..62783babe 100644
--- a/frontend/pages/api/integrations/DeleteIntegrationAuth.js
+++ b/frontend/pages/api/integrations/DeleteIntegrationAuth.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route deletes an integration authorization from a certain project
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const deleteIntegrationAuth = ({ integrationAuthId }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/integration-auth/" + integrationAuthId,
- {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to delete an integration authorization");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/integration-auth/" + integrationAuthId,
+ {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to delete an integration authorization");
+ }
+ });
};
export default deleteIntegrationAuth;
diff --git a/frontend/pages/api/integrations/GetIntegrationApps.js b/frontend/pages/api/integrations/GetIntegrationApps.js
index 3a483e618..d75891fd7 100644
--- a/frontend/pages/api/integrations/GetIntegrationApps.js
+++ b/frontend/pages/api/integrations/GetIntegrationApps.js
@@ -1,23 +1,23 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
const getIntegrationApps = ({ integrationAuthId }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/integration-auth/" + integrationAuthId + "/apps",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).apps;
- } else {
- console.log("Failed to get available apps for an integration");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/integration-auth/" + integrationAuthId + "/apps",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).apps;
+ } else {
+ console.log("Failed to get available apps for an integration");
+ }
+ });
};
export default getIntegrationApps;
diff --git a/frontend/pages/api/integrations/GetIntegrations.js b/frontend/pages/api/integrations/GetIntegrations.js
index 4f2608469..a8f1c9631 100644
--- a/frontend/pages/api/integrations/GetIntegrations.js
+++ b/frontend/pages/api/integrations/GetIntegrations.js
@@ -1,20 +1,20 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
const getIntegrations = () => {
- return SecurityClient.fetchCall(PATH + "/api/v1/integration/integrations", {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).integrations;
- } else {
- console.log("Failed to get project integrations");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/integration/integrations", {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).integrations;
+ } else {
+ console.log("Failed to get project integrations");
+ }
+ });
};
export default getIntegrations;
diff --git a/frontend/pages/api/integrations/StartIntegration.js b/frontend/pages/api/integrations/StartIntegration.js
index 820e21e1d..c9ecdcb44 100644
--- a/frontend/pages/api/integrations/StartIntegration.js
+++ b/frontend/pages/api/integrations/StartIntegration.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route starts the integration after teh default one if gonna set up.
@@ -8,28 +8,28 @@ import { PATH } from "../../../const";
* @returns
*/
const startIntegration = ({ integrationId, appName, environment }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/integration/" + integrationId,
- {
- method: "PATCH",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- update: {
- app: appName,
- environment,
- isActive: true,
- },
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to start an integration");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/integration/" + integrationId,
+ {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ update: {
+ app: appName,
+ environment,
+ isActive: true,
+ },
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to start an integration");
+ }
+ });
};
export default startIntegration;
diff --git a/frontend/pages/api/integrations/authorizeIntegration.js b/frontend/pages/api/integrations/authorizeIntegration.js
index efddf6f20..098ff7345 100644
--- a/frontend/pages/api/integrations/authorizeIntegration.js
+++ b/frontend/pages/api/integrations/authorizeIntegration.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This is the first step of the change password process (pake)
@@ -8,26 +8,26 @@ import { PATH } from "../../../const";
* @returns
*/
const AuthorizeIntegration = ({ workspaceId, code, integration }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/integration-auth/oauth-token",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- workspaceId,
- code,
- integration,
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to authorize the integration");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/integration-auth/oauth-token",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ workspaceId,
+ code,
+ integration,
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to authorize the integration");
+ }
+ });
};
export default AuthorizeIntegration;
diff --git a/frontend/pages/api/integrations/getWorkspaceAuthorizations.js b/frontend/pages/api/integrations/getWorkspaceAuthorizations.js
index a7ff51c4c..a5a3a3bba 100644
--- a/frontend/pages/api/integrations/getWorkspaceAuthorizations.js
+++ b/frontend/pages/api/integrations/getWorkspaceAuthorizations.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route gets authorizations of a certain project (Heroku, etc.)
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getWorkspaceAuthorizations = ({ workspaceId }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/workspace/" + workspaceId + "/authorizations",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).authorizations;
- } else {
- console.log("Failed to get project authorizations");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/workspace/" + workspaceId + "/authorizations",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).authorizations;
+ } else {
+ console.log("Failed to get project authorizations");
+ }
+ });
};
export default getWorkspaceAuthorizations;
diff --git a/frontend/pages/api/integrations/getWorkspaceIntegrations.js b/frontend/pages/api/integrations/getWorkspaceIntegrations.js
index 8789eb7ba..eb93f8883 100644
--- a/frontend/pages/api/integrations/getWorkspaceIntegrations.js
+++ b/frontend/pages/api/integrations/getWorkspaceIntegrations.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route gets integrations of a certain project (Heroku, etc.)
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getWorkspaceIntegrations = ({ workspaceId }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/workspace/" + workspaceId + "/integrations",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).integrations;
- } else {
- console.log("Failed to get the project integrations");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/workspace/" + workspaceId + "/integrations",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).integrations;
+ } else {
+ console.log("Failed to get the project integrations");
+ }
+ });
};
export default getWorkspaceIntegrations;
diff --git a/frontend/pages/api/organization/GetOrg.js b/frontend/pages/api/organization/GetOrg.js
index a977c8bb5..0a81d5da8 100644
--- a/frontend/pages/api/organization/GetOrg.js
+++ b/frontend/pages/api/organization/GetOrg.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get info about a certain org
@@ -9,21 +9,18 @@ import { PATH } from "../../../const";
* @returns
*/
const getOrganization = (req, res) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + req.orgId,
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).organization;
- } else {
- console.log("Failed to get org info");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/organization/" + req.orgId, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).organization;
+ } else {
+ console.log("Failed to get org info");
+ }
+ });
};
export default getOrganization;
diff --git a/frontend/pages/api/organization/GetOrgProjects.js b/frontend/pages/api/organization/GetOrgProjects.js
index 60ab3a6ce..dbec142a5 100644
--- a/frontend/pages/api/organization/GetOrgProjects.js
+++ b/frontend/pages/api/organization/GetOrgProjects.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get all the users in an org.
@@ -9,21 +9,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getOrganizationProjects = (req, res) => {
- return SecurityClient.fetchCall(
- PATH + "/api/organization/" + req.orgId + "/workspaces",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).workspaces;
- } else {
- console.log("Failed to get projects for an org");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/organization/" + req.orgId + "/workspaces",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).workspaces;
+ } else {
+ console.log("Failed to get projects for an org");
+ }
+ });
};
export default getOrganizationProjects;
diff --git a/frontend/pages/api/organization/GetOrgSubscription.js b/frontend/pages/api/organization/GetOrgSubscription.js
index bd71464a6..856725bf0 100644
--- a/frontend/pages/api/organization/GetOrgSubscription.js
+++ b/frontend/pages/api/organization/GetOrgSubscription.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get the current subscription of an org.
@@ -9,21 +9,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getOrganizationSubscriptions = (req, res) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + req.orgId + "/subscriptions",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).subscriptions;
- } else {
- console.log("Failed to get org subscriptions");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/organization/" + req.orgId + "/subscriptions",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).subscriptions;
+ } else {
+ console.log("Failed to get org subscriptions");
+ }
+ });
};
export default getOrganizationSubscriptions;
diff --git a/frontend/pages/api/organization/GetOrgUserProjects.js b/frontend/pages/api/organization/GetOrgUserProjects.js
index abff1f88c..869dbb232 100644
--- a/frontend/pages/api/organization/GetOrgUserProjects.js
+++ b/frontend/pages/api/organization/GetOrgUserProjects.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get all the projects of a certain user in an org.
@@ -9,21 +9,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getOrganizationUserProjects = (req, res) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + req.orgId + "/my-workspaces",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).workspaces;
- } else {
- console.log("Failed to get projects of a user in an org");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/organization/" + req.orgId + "/my-workspaces",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).workspaces;
+ } else {
+ console.log("Failed to get projects of a user in an org");
+ }
+ });
};
export default getOrganizationUserProjects;
diff --git a/frontend/pages/api/organization/GetOrgUsers.js b/frontend/pages/api/organization/GetOrgUsers.js
index 584e29de2..e4e8454eb 100644
--- a/frontend/pages/api/organization/GetOrgUsers.js
+++ b/frontend/pages/api/organization/GetOrgUsers.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get all the users in an org.
@@ -9,21 +9,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getOrganizationUsers = (req, res) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + req.orgId + "/users",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).users;
- } else {
- console.log("Failed to get org users");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/organization/" + req.orgId + "/users",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).users;
+ } else {
+ console.log("Failed to get org users");
+ }
+ });
};
export default getOrganizationUsers;
diff --git a/frontend/pages/api/organization/StripeRedirect.js b/frontend/pages/api/organization/StripeRedirect.js
index 158c1c811..f7cd7cb06 100644
--- a/frontend/pages/api/organization/StripeRedirect.js
+++ b/frontend/pages/api/organization/StripeRedirect.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route redirects the user to the right stripe billing page.
@@ -9,21 +9,21 @@ import { PATH } from "../../../const";
* @returns
*/
const StripeRedirect = ({ orgId }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + orgId + "/customer-portal-session",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (window.location.href = (await res.json()).url);
- } else {
- console.log("Failed to redirect to Stripe");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/organization/" + orgId + "/customer-portal-session",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (window.location.href = (await res.json()).url);
+ } else {
+ console.log("Failed to redirect to Stripe");
+ }
+ });
};
export default StripeRedirect;
diff --git a/frontend/pages/api/organization/addIncidentContact.js b/frontend/pages/api/organization/addIncidentContact.js
index db0b98d33..f5ca2729f 100644
--- a/frontend/pages/api/organization/addIncidentContact.js
+++ b/frontend/pages/api/organization/addIncidentContact.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route add an incident contact email to a certain organization
@@ -8,24 +8,24 @@ import { PATH } from "../../../const";
* @returns
*/
const addIncidentContact = (organizationId, email) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + organizationId + "/incidentContactOrg",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email: email,
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to add an incident contact");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/organization/" + organizationId + "/incidentContactOrg",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ email: email,
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to add an incident contact");
+ }
+ });
};
export default addIncidentContact;
diff --git a/frontend/pages/api/organization/addUserToOrg.js b/frontend/pages/api/organization/addUserToOrg.js
index e20a1676b..d807a3a7c 100644
--- a/frontend/pages/api/organization/addUserToOrg.js
+++ b/frontend/pages/api/organization/addUserToOrg.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This function sends an email invite to a user to join an org
@@ -9,22 +9,22 @@ import { PATH } from "../../../const";
* @returns
*/
const addUserToOrg = (email, orgId) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/invite-org/signup", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- inviteeEmail: email,
- organizationId: orgId,
- }),
- }).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to add a user to an org");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/invite-org/signup", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ inviteeEmail: email,
+ organizationId: orgId,
+ }),
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to add a user to an org");
+ }
+ });
};
export default addUserToOrg;
diff --git a/frontend/pages/api/organization/deleteIncidentContact.js b/frontend/pages/api/organization/deleteIncidentContact.js
index 3035c55ff..34d2e5a1e 100644
--- a/frontend/pages/api/organization/deleteIncidentContact.js
+++ b/frontend/pages/api/organization/deleteIncidentContact.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route deletes an incident Contact from a certain organization
@@ -8,24 +8,24 @@ import { PATH } from "../../../const";
* @returns
*/
const deleteIncidentContact = (organizaionId, email) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + organizaionId + "/incidentContactOrg",
- {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email: email,
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to delete an incident contact");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/organization/" + organizaionId + "/incidentContactOrg",
+ {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ email: email,
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to delete an incident contact");
+ }
+ });
};
export default deleteIncidentContact;
diff --git a/frontend/pages/api/organization/deleteUserFromOrganization.js b/frontend/pages/api/organization/deleteUserFromOrganization.js
index b9fcf15e6..8beadf0c1 100644
--- a/frontend/pages/api/organization/deleteUserFromOrganization.js
+++ b/frontend/pages/api/organization/deleteUserFromOrganization.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This function removes a certain member from a certain organization
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const deleteUserFromOrganization = (membershipId) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/membership-org/" + membershipId,
- {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to delete a user from an org");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/membership-org/" + membershipId,
+ {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to delete a user from an org");
+ }
+ });
};
export default deleteUserFromOrganization;
diff --git a/frontend/pages/api/organization/getIncidentContacts.js b/frontend/pages/api/organization/getIncidentContacts.js
index f5d54aa0a..9eb76242a 100644
--- a/frontend/pages/api/organization/getIncidentContacts.js
+++ b/frontend/pages/api/organization/getIncidentContacts.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This routes gets all the incident contacts of a certain organization
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getIncidentContacts = (organizationId) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + organizationId + "/incidentContactOrg",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).incidentContactsOrg;
- } else {
- console.log("Failed to get incident contacts");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/organization/" + organizationId + "/incidentContactOrg",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).incidentContactsOrg;
+ } else {
+ console.log("Failed to get incident contacts");
+ }
+ });
};
export default getIncidentContacts;
diff --git a/frontend/pages/api/organization/getOrgs.js b/frontend/pages/api/organization/getOrgs.js
index 80847664a..501911f3c 100644
--- a/frontend/pages/api/organization/getOrgs.js
+++ b/frontend/pages/api/organization/getOrgs.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get the all the orgs of a certain user.
@@ -9,18 +9,18 @@ import { PATH } from "../../../const";
* @returns
*/
const getOrganizations = (req, res) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/organization", {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).organizations;
- } else {
- console.log("Failed to get orgs of a user");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/organization", {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).organizations;
+ } else {
+ console.log("Failed to get orgs of a user");
+ }
+ });
};
export default getOrganizations;
diff --git a/frontend/pages/api/organization/renameOrg.js b/frontend/pages/api/organization/renameOrg.js
index afcc94981..ddd3ad939 100644
--- a/frontend/pages/api/organization/renameOrg.js
+++ b/frontend/pages/api/organization/renameOrg.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us rename a certain org.
@@ -9,24 +9,24 @@ import { PATH } from "../../../const";
* @returns
*/
const renameOrg = (orgId, newOrgName) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/organization/" + orgId + "/name",
- {
- method: "PATCH",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- name: newOrgName,
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to rename an organization");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/organization/" + orgId + "/name",
+ {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ name: newOrgName,
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to rename an organization");
+ }
+ });
};
export default renameOrg;
diff --git a/frontend/pages/api/serviceToken/addServiceToken.js b/frontend/pages/api/serviceToken/addServiceToken.js
index fec30ec95..b101c97db 100644
--- a/frontend/pages/api/serviceToken/addServiceToken.js
+++ b/frontend/pages/api/serviceToken/addServiceToken.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route gets service tokens for a specific user in a project
@@ -8,35 +8,35 @@ import { PATH } from "../../../const";
* @returns
*/
const addServiceToken = ({
- name,
- workspaceId,
- environment,
- expiresIn,
- publicKey,
- encryptedKey,
- nonce,
+ name,
+ workspaceId,
+ environment,
+ expiresIn,
+ publicKey,
+ encryptedKey,
+ nonce,
}) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/service-token/", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- name,
- workspaceId,
- environment,
- expiresIn,
- publicKey,
- encryptedKey,
- nonce,
- }),
- }).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).token;
- } else {
- console.log("Failed to add service tokens");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/service-token/", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ name,
+ workspaceId,
+ environment,
+ expiresIn,
+ publicKey,
+ encryptedKey,
+ nonce,
+ }),
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).token;
+ } else {
+ console.log("Failed to add service tokens");
+ }
+ });
};
export default addServiceToken;
diff --git a/frontend/pages/api/serviceToken/getServiceTokens.js b/frontend/pages/api/serviceToken/getServiceTokens.js
index 39674e711..a09acb2de 100644
--- a/frontend/pages/api/serviceToken/getServiceTokens.js
+++ b/frontend/pages/api/serviceToken/getServiceTokens.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route gets service tokens for a specific user in a project
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getServiceTokens = ({ workspaceId }) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/workspace/" + workspaceId + "/service-tokens",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).serviceTokens;
- } else {
- console.log("Failed to get service tokens");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/workspace/" + workspaceId + "/service-tokens",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).serviceTokens;
+ } else {
+ console.log("Failed to get service tokens");
+ }
+ });
};
export default getServiceTokens;
diff --git a/frontend/pages/api/user/getUser.js b/frontend/pages/api/user/getUser.js
index 3491810f5..0f5004433 100644
--- a/frontend/pages/api/user/getUser.js
+++ b/frontend/pages/api/user/getUser.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route gets the information about a specific user.
@@ -9,18 +9,18 @@ import { PATH } from "../../../const";
* @returns
*/
const getUser = (req, res) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/user", {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).user;
- } else {
- console.log("Failed to get user info");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/user", {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).user;
+ } else {
+ console.log("Failed to get user info");
+ }
+ });
};
export default getUser;
diff --git a/frontend/pages/api/userActions/checkUserAction.js b/frontend/pages/api/userActions/checkUserAction.js
index ae71ddbe2..fa70d2844 100644
--- a/frontend/pages/api/userActions/checkUserAction.js
+++ b/frontend/pages/api/userActions/checkUserAction.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route registers a certain action for a user
@@ -9,26 +9,26 @@ import { PATH } from "../../../const";
* @returns
*/
const checkUserAction = ({ action }) => {
- return SecurityClient.fetchCall(
- PATH +
- "/api/v1/user-action" +
- "?" +
- new URLSearchParams({
- action,
- }),
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).userAction;
- } else {
- console.log("Failed to check a user action");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH +
+ "/api/v1/user-action" +
+ "?" +
+ new URLSearchParams({
+ action,
+ }),
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).userAction;
+ } else {
+ console.log("Failed to check a user action");
+ }
+ });
};
export default checkUserAction;
diff --git a/frontend/pages/api/userActions/registerUserAction.js b/frontend/pages/api/userActions/registerUserAction.js
index 64d937015..9fae67e6e 100644
--- a/frontend/pages/api/userActions/registerUserAction.js
+++ b/frontend/pages/api/userActions/registerUserAction.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route registers a certain action for a user
@@ -8,21 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const registerUserAction = ({ action }) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/user-action", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- action,
- }),
- }).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to register a user action");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/user-action", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ action,
+ }),
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to register a user action");
+ }
+ });
};
export default registerUserAction;
diff --git a/frontend/pages/api/workspace/addUserToWorkspace.js b/frontend/pages/api/workspace/addUserToWorkspace.js
index a598a6a4d..1e5d9a212 100644
--- a/frontend/pages/api/workspace/addUserToWorkspace.js
+++ b/frontend/pages/api/workspace/addUserToWorkspace.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This function adds a user to a project
@@ -9,24 +9,24 @@ import { PATH } from "../../../const";
* @returns
*/
const addUserToWorkspace = (email, workspaceId) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/workspace/" + workspaceId + "/invite-signup",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- email: email,
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return await res.json();
- } else {
- console.log("Failed to add a user to project");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/workspace/" + workspaceId + "/invite-signup",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ email: email,
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return await res.json();
+ } else {
+ console.log("Failed to add a user to project");
+ }
+ });
};
export default addUserToWorkspace;
diff --git a/frontend/pages/api/workspace/changeUserRoleInWorkspace.js b/frontend/pages/api/workspace/changeUserRoleInWorkspace.js
index 3d9f4a36a..7d0fb629e 100644
--- a/frontend/pages/api/workspace/changeUserRoleInWorkspace.js
+++ b/frontend/pages/api/workspace/changeUserRoleInWorkspace.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This function change the access of a user in a certain workspace
@@ -9,24 +9,24 @@ import { PATH } from "../../../const";
* @returns
*/
const changeUserRoleInWorkspace = (membershipId, role) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/membership/" + membershipId + "/change-role",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- role: role,
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to change the user role in a project");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/membership/" + membershipId + "/change-role",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ role: role,
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to change the user role in a project");
+ }
+ });
};
export default changeUserRoleInWorkspace;
diff --git a/frontend/pages/api/workspace/createWorkspace.js b/frontend/pages/api/workspace/createWorkspace.js
index 13c57245b..ac61e22e1 100644
--- a/frontend/pages/api/workspace/createWorkspace.js
+++ b/frontend/pages/api/workspace/createWorkspace.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route creates a new workspace for a user.
@@ -8,22 +8,22 @@ import { PATH } from "../../../const";
* @returns
*/
const createWorkspace = (workspaceName, organizationId) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/workspace", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- workspaceName: workspaceName,
- organizationId: organizationId,
- }),
- }).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).workspace;
- } else {
- console.log("Failed to create a project");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/workspace", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ workspaceName: workspaceName,
+ organizationId: organizationId,
+ }),
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).workspace;
+ } else {
+ console.log("Failed to create a project");
+ }
+ });
};
export default createWorkspace;
diff --git a/frontend/pages/api/workspace/deleteUserFromWorkspace.js b/frontend/pages/api/workspace/deleteUserFromWorkspace.js
index 6aa2559a3..6fdeaa9c1 100644
--- a/frontend/pages/api/workspace/deleteUserFromWorkspace.js
+++ b/frontend/pages/api/workspace/deleteUserFromWorkspace.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This function removes a certain member from a certain workspace
@@ -8,21 +8,18 @@ import { PATH } from "../../../const";
* @returns
*/
const deleteUserFromWorkspace = (membershipId) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/membership/" + membershipId,
- {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to delete a user from a project");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/membership/" + membershipId, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to delete a user from a project");
+ }
+ });
};
export default deleteUserFromWorkspace;
diff --git a/frontend/pages/api/workspace/deleteWorkspace.js b/frontend/pages/api/workspace/deleteWorkspace.js
index f2e415c05..3bb8f27af 100644
--- a/frontend/pages/api/workspace/deleteWorkspace.js
+++ b/frontend/pages/api/workspace/deleteWorkspace.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route deletes a specified workspace.
@@ -8,18 +8,18 @@ import { PATH } from "../../../const";
* @returns
*/
const deleteWorkspace = (workspaceId) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId, {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
- }).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to delete a project");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to delete a project");
+ }
+ });
};
export default deleteWorkspace;
diff --git a/frontend/pages/api/workspace/getLatestFileKey.js b/frontend/pages/api/workspace/getLatestFileKey.js
index f6f61b64f..772962b31 100644
--- a/frontend/pages/api/workspace/getLatestFileKey.js
+++ b/frontend/pages/api/workspace/getLatestFileKey.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* Get the latest key pairs from a certain workspace
@@ -8,23 +8,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getLatestFileKey = (workspaceId) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/key/" + workspaceId + "/latest",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return await res.json();
- } else {
- console.log(
- "Failed to get the latest key pairs for a certain project"
- );
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/key/" + workspaceId + "/latest",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return await res.json();
+ } else {
+ console.log("Failed to get the latest key pairs for a certain project");
+ }
+ });
};
export default getLatestFileKey;
diff --git a/frontend/pages/api/workspace/getWorkspaceInfo.js b/frontend/pages/api/workspace/getWorkspaceInfo.js
index 5e510447d..7c0cbd1fd 100644
--- a/frontend/pages/api/workspace/getWorkspaceInfo.js
+++ b/frontend/pages/api/workspace/getWorkspaceInfo.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get the information of a certain project.
@@ -9,21 +9,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getWorkspaceInfo = (req, res) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/workspace/" + req.workspaceId,
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).workspace;
- } else {
- console.log("Failed to get project info");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/workspace/" + req.workspaceId,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).workspace;
+ } else {
+ console.log("Failed to get project info");
+ }
+ });
};
export default getWorkspaceInfo;
diff --git a/frontend/pages/api/workspace/getWorkspaceKeys.js b/frontend/pages/api/workspace/getWorkspaceKeys.js
index 334f1a878..37849aec0 100644
--- a/frontend/pages/api/workspace/getWorkspaceKeys.js
+++ b/frontend/pages/api/workspace/getWorkspaceKeys.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get the public keys of everyone in your workspace.
@@ -9,23 +9,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getWorkspaceKeys = (req, res) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/workspace/" + req.workspaceId + "/keys",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).publicKeys;
- } else {
- console.log(
- "Failed to get the public keys of everyone in the workspace"
- );
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/workspace/" + req.workspaceId + "/keys",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).publicKeys;
+ } else {
+ console.log("Failed to get the public keys of everyone in the workspace");
+ }
+ });
};
export default getWorkspaceKeys;
diff --git a/frontend/pages/api/workspace/getWorkspaceUsers.js b/frontend/pages/api/workspace/getWorkspaceUsers.js
index 3dc05a2f5..3b95fcbfd 100644
--- a/frontend/pages/api/workspace/getWorkspaceUsers.js
+++ b/frontend/pages/api/workspace/getWorkspaceUsers.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get all the users in the workspace.
@@ -9,21 +9,21 @@ import { PATH } from "../../../const";
* @returns
*/
const getWorkspaceUsers = (req, res) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/workspace/" + req.workspaceId + "/users",
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).users;
- } else {
- console.log("Failed to get Project Users");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/workspace/" + req.workspaceId + "/users",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).users;
+ } else {
+ console.log("Failed to get Project Users");
+ }
+ });
};
export default getWorkspaceUsers;
diff --git a/frontend/pages/api/workspace/getWorkspaces.js b/frontend/pages/api/workspace/getWorkspaces.js
index 0e751a319..0cb874908 100644
--- a/frontend/pages/api/workspace/getWorkspaces.js
+++ b/frontend/pages/api/workspace/getWorkspaces.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us get the public keys of everyone in your workspace.
@@ -9,18 +9,18 @@ import { PATH } from "../../../const";
* @returns
*/
const getWorkspaces = (req, res) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/workspace", {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }).then(async (res) => {
- if (res.status == 200) {
- return (await res.json()).workspaces;
- } else {
- console.log("Failed to get projects");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/workspace", {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return (await res.json()).workspaces;
+ } else {
+ console.log("Failed to get projects");
+ }
+ });
};
export default getWorkspaces;
diff --git a/frontend/pages/api/workspace/renameWorkspace.js b/frontend/pages/api/workspace/renameWorkspace.js
index 0547c481b..71ed7039e 100644
--- a/frontend/pages/api/workspace/renameWorkspace.js
+++ b/frontend/pages/api/workspace/renameWorkspace.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route lets us rename a certain workspace.
@@ -9,24 +9,24 @@ import { PATH } from "../../../const";
* @returns
*/
const renameWorkspace = (workspaceId, newWorkspaceName) => {
- return SecurityClient.fetchCall(
- PATH + "/api/v1/workspace/" + workspaceId + "/name",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- name: newWorkspaceName,
- }),
- }
- ).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to rename a project");
- }
- });
+ return SecurityClient.fetchCall(
+ PATH + "/api/v1/workspace/" + workspaceId + "/name",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ name: newWorkspaceName,
+ }),
+ }
+ ).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to rename a project");
+ }
+ });
};
export default renameWorkspace;
diff --git a/frontend/pages/api/workspace/uploadKeys.js b/frontend/pages/api/workspace/uploadKeys.js
index 3b2593cb8..eac6e6e51 100644
--- a/frontend/pages/api/workspace/uploadKeys.js
+++ b/frontend/pages/api/workspace/uploadKeys.js
@@ -1,6 +1,6 @@
import SecurityClient from "~/utilities/SecurityClient";
-import { PATH } from "../../../const";
+import { PATH } from "~/const";
/**
* This route uplods the keys in an encrypted format.
@@ -11,25 +11,25 @@ import { PATH } from "../../../const";
* @returns
*/
const uploadKeys = (workspaceId, userId, encryptedKey, nonce) => {
- return SecurityClient.fetchCall(PATH + "/api/v1/key/" + workspaceId, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- key: {
- userId: userId,
- encryptedKey: encryptedKey,
- nonce: nonce,
- },
- }),
- }).then(async (res) => {
- if (res.status == 200) {
- return res;
- } else {
- console.log("Failed to upload keys for a new user");
- }
- });
+ return SecurityClient.fetchCall(PATH + "/api/v1/key/" + workspaceId, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ key: {
+ userId: userId,
+ encryptedKey: encryptedKey,
+ nonce: nonce,
+ },
+ }),
+ }).then(async (res) => {
+ if (res.status == 200) {
+ return res;
+ } else {
+ console.log("Failed to upload keys for a new user");
+ }
+ });
};
export default uploadKeys;