fix: auth redirection issues in the web, space and admin apps (#4414)

* fix: login redirection

* dev: log the user out when deactivating the account

* dev: update redirect uris for google and github

* fix: redirection url and invitation api and add redirection to god mode in nginx

* dev: add reset password redirection

* dev: update nginx headers

* dev: fix setup sh and env example and put validation for use minio when fetching project covers

* dev: stabilize dev setup

* fix: handled redirection error in web, space, and admin apps

* fix: resovled build errors

---------

Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
This commit is contained in:
guru_sainath 2024-05-09 17:46:31 +05:30 committed by GitHub
parent 692f570258
commit 58bf056ddb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 250 additions and 172 deletions

2
space/.env.example Normal file
View file

@ -0,0 +1,2 @@
NEXT_PUBLIC_APP_URL=
NEXT_PUBLIC_API_BASE_URL=

View file

@ -1,7 +1,7 @@
import { useContext } from "react";
// store
import { StoreContext } from "@/lib/store-context";
import { IUserStore } from "@/store/user/index.store";
import { IUserStore } from "@/store/user";
export const useUser = (): IUserStore => {
const context = useContext(StoreContext);

View file

@ -2,7 +2,7 @@ import { ReactElement, createContext } from "react";
// mobx store
import { RootStore } from "@/store/root.store";
let rootStore = new RootStore();
export let rootStore = new RootStore();
export const StoreContext = createContext<RootStore>(rootStore);

View file

@ -11,7 +11,7 @@ import { StoreProvider } from "@/lib/store-context";
// wrappers
import { InstanceWrapper } from "@/lib/wrappers";
const prefix = parseInt(process.env.NEXT_PUBLIC_DEPLOY_WITH_NGINX || "0") === 0 ? "/" : "/spaces/";
const prefix = "/spaces/";
function MyApp({ Component, pageProps }: AppProps) {
return (

View file

@ -1,5 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import axios, { AxiosInstance } from "axios";
// store
import { rootStore } from "@/lib/store-context";
abstract class APIService {
protected baseURL: string;
@ -19,7 +21,8 @@ abstract class APIService {
this.axiosInstance.interceptors.response.use(
(response) => response,
(error) => {
if (error.response && error.response.status === 401) window.location.href = "/";
const store = rootStore;
if (error.response && error.response.status === 401 && store.user.data) store.user.reset();
return Promise.reject(error);
}
);

View file

@ -3,7 +3,7 @@ import { enableStaticRendering } from "mobx-react-lite";
// store imports
import { IInstanceStore, InstanceStore } from "@/store/instance.store";
import { IProjectStore, ProjectStore } from "@/store/project";
import { IUserStore, UserStore } from "@/store/user/index.store";
import { IUserStore, UserStore } from "@/store/user";
import { IProfileStore, ProfileStore } from "@/store/user/profile.store";
import IssueStore, { IIssueStore } from "./issue";

View file

@ -2,8 +2,6 @@ import set from "lodash/set";
import { action, computed, makeObservable, observable, runInAction } from "mobx";
// types
import { IUser } from "@plane/types";
// helpers
// import { API_BASE_URL } from "@/helpers/common.helper";
// services
import { AuthService } from "@/services/authentication.service";
import { UserService } from "@/services/user.service";
@ -30,6 +28,7 @@ export interface IUserStore {
// actions
fetchCurrentUser: () => Promise<IUser | undefined>;
updateCurrentUser: (data: Partial<IUser>) => Promise<IUser | undefined>;
reset: () => void;
signOut: () => Promise<void>;
}
@ -65,6 +64,7 @@ export class UserStore implements IUserStore {
// actions
fetchCurrentUser: action,
updateCurrentUser: action,
reset: action,
signOut: action,
});
}
@ -153,6 +153,20 @@ export class UserStore implements IUserStore {
}
};
/**
* @description resets the user store
* @returns {void}
*/
reset = (): void => {
runInAction(() => {
this.isAuthenticated = false;
this.isLoading = false;
this.error = undefined;
this.data = undefined;
this.userProfile = new ProfileStore(this.store);
});
};
/**
* @description signs out the current user
* @returns {Promise<void>}