Răsfoiți Sursa

invite flow force email (#2865)

Co-authored-by: jusrhee <justin@porter.run>
sunguroku 3 ani în urmă
părinte
comite
6b31f65451

+ 4 - 0
dashboard/src/components/porter/Input.tsx

@@ -1,5 +1,6 @@
 import React, { useEffect, useState } from "react";
 import styled from "styled-components";
+import { boolean } from "zod";
 
 type Props = {
   placeholder: string;
@@ -11,6 +12,7 @@ type Props = {
   type?: string;
   error?: string;
   children?: React.ReactNode;
+  disabled?: boolean;
 };
 
 const Input: React.FC<Props> = ({
@@ -23,6 +25,7 @@ const Input: React.FC<Props> = ({
   type,
   error,
   children,
+  disabled,
 }) => {
   return (
     <Block width={width}>
@@ -39,6 +42,7 @@ const Input: React.FC<Props> = ({
         height={height}
         type={type || "text"}
         hasError={(error && true) || (error === "")}
+        disabled={disabled ? disabled : false}
       />
       {
         error && (

+ 14 - 0
dashboard/src/main/auth/Register.tsx

@@ -38,6 +38,7 @@ const Register: React.FC<Props> = ({
   const [companyNameError, setCompanyNameError] = useState(false);
   const [email, setEmail] = useState("");
   const [emailError, setEmailError] = useState(false);
+  const [disabled, setDisabled] = useState(false);
   const [password, setPassword] = useState("");
   const [passwordError, setPasswordError] = useState(false);
   const [hasBasic, setHasBasic] = useState(true);
@@ -118,6 +119,18 @@ const Register: React.FC<Props> = ({
     };
   }, [email, password, firstName, lastName]);
 
+  useEffect(() => {
+    let qs = window.location.search;
+    let urlParams = new URLSearchParams(qs);
+    let email = urlParams.get('email');
+    
+    if (email) {
+      setEmail(email);
+      setDisabled(true);
+    }
+    
+  }, []);
+
   useEffect(() => {
 
     // Get capabilities to case on login methods
@@ -273,6 +286,7 @@ const Register: React.FC<Props> = ({
               width="100%"
               height="40px"
               error={(emailError && "Please enter a valid email")}
+              disabled={disabled}
             />
             <Spacer y={1} />
             <Input

+ 1 - 1
ee/api/server/handlers/invite/accept.go

@@ -104,5 +104,5 @@ func (c *InviteAcceptHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 		return
 	}
 
-	http.Redirect(w, r, "/dashboard", 302)
+	http.Redirect(w, r, fmt.Sprintf("/register?email=%s", invite.Email), 302)
 }