Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

fix: next_path enabled for oauth auth (#4526)

guru_sainath1355873e32cf
diff --git a/space/components/account/oauth/github-button.tsx b/space/components/account/oauth/github-button.tsx
index 41e6b7f923..ba65f38c4d 100644
--- a/space/components/account/oauth/github-button.tsx
+++ b/space/components/account/oauth/github-button.tsx
@@ -1,4 +1,5 @@
import { FC } from "react";
+import { useSearchParams } from "next/navigation";
import Image from "next/image";
import { useTheme } from "next-themes";
// helpers
@@ -12,12 +13,14 @@ export type GithubOAuthButtonProps = {
};
export const GithubOAuthButton: FC<GithubOAuthButtonProps> = (props) => {
+ const searchParams = useSearchParams();
+ const nextPath = searchParams.get("next_path") || undefined;
const { text } = props;
// hooks
const { resolvedTheme } = useTheme();
const handleSignIn = () => {
- window.location.assign(`${API_BASE_URL}/auth/spaces/github/`);
+ window.location.assign(`${API_BASE_URL}/auth/spaces/github/${nextPath ? `?next_path=${nextPath}` : ``}`);
};
return (
diff --git a/space/components/account/oauth/google-button.tsx b/space/components/account/oauth/google-button.tsx
index d31c6f59fb..179b1c35ad 100644
--- a/space/components/account/oauth/google-button.tsx
+++ b/space/components/account/oauth/google-button.tsx
@@ -1,4 +1,5 @@
import { FC } from "react";
+import { useSearchParams } from "next/navigation";
import Image from "next/image";
import { useTheme } from "next-themes";
// helpers
@@ -11,12 +12,14 @@ export type GoogleOAuthButtonProps = {
};
export const GoogleOAuthButton: FC<GoogleOAuthButtonProps> = (props) => {
+ const searchParams = useSearchParams();
+ const nextPath = searchParams.get("next_path") || undefined;
const { text } = props;
// hooks
const { resolvedTheme } = useTheme();
const handleSignIn = () => {
- window.location.assign(`${API_BASE_URL}/auth/spaces/google/`);
+ window.location.assign(`${API_BASE_URL}/auth/spaces/google/${nextPath ? `?next_path=${nextPath}` : ``}`);
};
return (
diff --git a/web/components/account/oauth/github-button.tsx b/web/components/account/oauth/github-button.tsx
index 317cebe31b..be9b59f249 100644
--- a/web/components/account/oauth/github-button.tsx
+++ b/web/components/account/oauth/github-button.tsx
@@ -1,4 +1,5 @@
import { FC } from "react";
+import { useRouter } from "next/router";
import Image from "next/image";
import { useTheme } from "next-themes";
// helpers
@@ -12,12 +13,14 @@ export type GithubOAuthButtonProps = {
};
export const GithubOAuthButton: FC<GithubOAuthButtonProps> = (props) => {
+ const { query } = useRouter();
+ const { next_path } = query;
const { text } = props;
// hooks
const { resolvedTheme } = useTheme();
const handleSignIn = () => {
- window.location.assign(`${API_BASE_URL}/auth/github/`);
+ window.location.assign(`${API_BASE_URL}/auth/github/${next_path ? `?next_path=${next_path}` : ``}`);
};
return (
diff --git a/web/components/account/oauth/google-button.tsx b/web/components/account/oauth/google-button.tsx
index 2b3df49315..d196ff97a3 100644
--- a/web/components/account/oauth/google-button.tsx
+++ b/web/components/account/oauth/google-button.tsx
@@ -1,4 +1,5 @@
import { FC } from "react";
+import { useRouter } from "next/router";
import Image from "next/image";
import { useTheme } from "next-themes";
// helpers
@@ -11,12 +12,14 @@ export type GoogleOAuthButtonProps = {
};
export const GoogleOAuthButton: FC<GoogleOAuthButtonProps> = (props) => {
+ const { query } = useRouter();
+ const { next_path } = query;
const { text } = props;
// hooks
const { resolvedTheme } = useTheme();
const handleSignIn = () => {
- window.location.assign(`${API_BASE_URL}/auth/google/`);
+ window.location.assign(`${API_BASE_URL}/auth/google/${next_path ? `?next_path=${next_path}` : ``}`);
};
return (