Skip to content

Commit

Permalink
fix: next_path enabled for oauth auth (#4526)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurusainath committed May 20, 2024
1 parent 836452f commit 1355873
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion space/components/account/oauth/github-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";
import { useSearchParams } from "next/navigation";
import Image from "next/image";
import { useTheme } from "next-themes";
// helpers
Expand All @@ -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 (
Expand Down
5 changes: 4 additions & 1 deletion space/components/account/oauth/google-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";
import { useSearchParams } from "next/navigation";
import Image from "next/image";
import { useTheme } from "next-themes";
// helpers
Expand All @@ -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 (
Expand Down
5 changes: 4 additions & 1 deletion web/components/account/oauth/github-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";
import { useRouter } from "next/router";
import Image from "next/image";
import { useTheme } from "next-themes";
// helpers
Expand All @@ -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 (
Expand Down
5 changes: 4 additions & 1 deletion web/components/account/oauth/google-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";
import { useRouter } from "next/router";
import Image from "next/image";
import { useTheme } from "next-themes";
// helpers
Expand All @@ -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 (
Expand Down

0 comments on commit 1355873

Please sign in to comment.