Adds BASE_URL to callbackUrl in signup page and Shell component (#1882)
* add WEBSITE_URL to callbackUrl in signup page and Shell component * fix: WEBSITE_URL -> BASE_URL, login missing do in another pr maybe Co-authored-by: Agusti Fernandez <agusti@colony.io> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Agusti Fernandez <git@agusti.me> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									9863178025
								
							
						
					
					
						commit
						373bc1660c
					
				
					 2 changed files with 13 additions and 4 deletions
				
			
		|  | @ -22,6 +22,7 @@ import TrialBanner from "@ee/components/TrialBanner"; | |||
| import HelpMenuItemDynamic from "@ee/lib/intercom/HelpMenuItemDynamic"; | ||||
| 
 | ||||
| import classNames from "@lib/classNames"; | ||||
| import { BASE_URL } from "@lib/config/constants"; | ||||
| import { shouldShowOnboarding } from "@lib/getting-started"; | ||||
| import { useLocale } from "@lib/hooks/useLocale"; | ||||
| import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; | ||||
|  | @ -61,7 +62,7 @@ function useRedirectToLoginIfUnauthenticated() { | |||
|       router.replace({ | ||||
|         pathname: "/auth/login", | ||||
|         query: { | ||||
|           callbackUrl: `${location.pathname}${location.search}`, | ||||
|           callbackUrl: `${BASE_URL}/${location.pathname}${location.search}`, | ||||
|         }, | ||||
|       }); | ||||
|     } | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ import { useRouter } from "next/router"; | |||
| import { FormProvider, SubmitHandler, useForm } from "react-hook-form"; | ||||
| 
 | ||||
| import { asStringOrNull } from "@lib/asStringOrNull"; | ||||
| import { BASE_URL } from "@lib/config/constants"; | ||||
| import { useLocale } from "@lib/hooks/useLocale"; | ||||
| import prisma from "@lib/prisma"; | ||||
| import { isSAMLLoginEnabled } from "@lib/saml"; | ||||
|  | @ -56,7 +57,12 @@ export default function Signup({ email }: Props) { | |||
|       method: "POST", | ||||
|     }) | ||||
|       .then(handleErrors) | ||||
|       .then(async () => await signIn("Cal.com", { callbackUrl: (router.query.callbackUrl || "") as string })) | ||||
|       .then( | ||||
|         async () => | ||||
|           await signIn("Cal.com", { | ||||
|             callbackUrl: (`${BASE_URL}/${router.query.callbackUrl}` || "") as string, | ||||
|           }) | ||||
|       ) | ||||
|       .catch((err) => { | ||||
|         methods.setError("apiError", { message: err.message }); | ||||
|       }); | ||||
|  | @ -123,7 +129,9 @@ export default function Signup({ email }: Props) { | |||
|                   color="secondary" | ||||
|                   className="w-5/12 justify-center" | ||||
|                   onClick={() => | ||||
|                     signIn("Cal.com", { callbackUrl: (router.query.callbackUrl || "") as string }) | ||||
|                     signIn("Cal.com", { | ||||
|                       callbackUrl: (`${BASE_URL}/${router.query.callbackUrl}` || "") as string, | ||||
|                     }) | ||||
|                   }> | ||||
|                   {t("login_instead")} | ||||
|                 </Button> | ||||
|  | @ -176,7 +184,7 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { | |||
|     return { | ||||
|       redirect: { | ||||
|         permanent: false, | ||||
|         destination: "/auth/login?callbackUrl=" + ctx.query.callbackUrl, | ||||
|         destination: "/auth/login?callbackUrl=" + `${BASE_URL}/${ctx.query.callbackUrl}`, | ||||
|       }, | ||||
|     }; | ||||
|   } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Agusti Fernandez
						Agusti Fernandez