chore: deploy code refactor (#3019)

* chore: deploy code refactor

* fix: next_path redirection

* fix: sanitized pathname

---------

Co-authored-by: gurusainath <gurusainath007@gmail.com>
Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
Anmol Singh Bhatia 2023-12-07 18:50:09 +05:30 committed by GitHub
parent e2e91f4aae
commit b0f690d322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 20 deletions

View File

@ -174,7 +174,7 @@ const IssueNavbar = observer(() => {
</div> </div>
) : ( ) : (
<div className="flex-shrink-0"> <div className="flex-shrink-0">
<Link href={`/login/?next_path=${router.asPath}`}> <Link href={`/?next_path=${router.asPath}`}>
<Button variant="outline-primary">Sign in</Button> <Button variant="outline-primary">Sign in</Button>
</Link> </Link>
</div> </div>

View File

@ -30,7 +30,7 @@ const useSignInRedirection = (): UseSignInRedirectionProps => {
if (isOnboard) { if (isOnboard) {
// if next_path is provided, redirect the user to that url // if next_path is provided, redirect the user to that url
if (next_path) router.push(next_path.toString()); if (next_path) router.push(next_path.toString());
else router.push("/login"); else router.push("/");
} else { } else {
// if the user profile is not complete, redirect them to the onboarding page to complete their profile and then redirect them to the next path // if the user profile is not complete, redirect them to the onboarding page to complete their profile and then redirect them to the next path
if (next_path) router.push(`/onboarding?next_path=${next_path}`); if (next_path) router.push(`/onboarding?next_path=${next_path}`);

View File

@ -1,19 +1,28 @@
import { useEffect } from "react"; import { useEffect } from "react";
// next
import { NextPage } from "next"; import { NextPage } from "next";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
const Index: NextPage = () => { // components
import { LoginView } from "components/views";
// store
import { RootStore } from "store/root";
import { useMobxStore } from "lib/mobx/store-provider";
const Index: NextPage = observer(() => {
const router = useRouter(); const router = useRouter();
const { next_path } = router.query as { next_path: string }; const { next_path } = router.query;
const {
user: { currentUser },
}: RootStore = useMobxStore();
useEffect(() => { useEffect(() => {
if (next_path) router.push(`/login?next_path=${next_path}`); if (next_path && currentUser?.onboarding_step?.profile_complete)
else router.push(`/login`); router.push(next_path.toString().replace(/[^a-zA-Z0-9\-._~:/?#[\]@!$&'()*+,;=]/g, ""));
}, [router, next_path]); }, [router, next_path, currentUser]);
return null; return <LoginView />;
}; });
export default Index; export default Index;

View File

@ -1,8 +0,0 @@
import React from "react";
// components
import { LoginView } from "components/views";
const LoginPage = () => <LoginView />;
export default LoginPage;

View File

@ -2797,7 +2797,7 @@
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"
"@types/react@*", "@types/react@^18.2.39", "@types/react@^18.2.42": "@types/react@*", "@types/react@18.2.42", "@types/react@^18.2.39", "@types/react@^18.2.42":
version "18.2.42" version "18.2.42"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.42.tgz#6f6b11a904f6d96dda3c2920328a97011a00aba7" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.42.tgz#6f6b11a904f6d96dda3c2920328a97011a00aba7"
integrity sha512-c1zEr96MjakLYus/wPnuWDo1/zErfdU9rNsIGmE+NV71nx88FG9Ttgo5dqorXTu/LImX2f63WBP986gJkMPNbA== integrity sha512-c1zEr96MjakLYus/wPnuWDo1/zErfdU9rNsIGmE+NV71nx88FG9Ttgo5dqorXTu/LImX2f63WBP986gJkMPNbA==