Browse Source

store names in db

Justin Rhee 3 years ago
parent
commit
6e994694bf

+ 4 - 2
api/server/handlers/user/create.go

@@ -40,8 +40,10 @@ func (u *UserCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	}
 
 	user := &models.User{
-		Email:    request.Email,
-		Password: request.Password,
+		Email:     request.Email,
+		Password:  request.Password,
+		FirstName: request.FirstName,
+		LastName:  request.LastName,
 	}
 
 	// check if user exists

+ 6 - 2
api/types/user.go

@@ -4,11 +4,15 @@ type User struct {
 	ID            uint   `json:"id"`
 	Email         string `json:"email"`
 	EmailVerified bool   `json:"email_verified"`
+	FirstName     string `json:"first_name"`
+	LastName      string `json:"last_name"`
 }
 
 type CreateUserRequest struct {
-	Email    string `json:"email" form:"required,max=255,email"`
-	Password string `json:"password" form:"required,max=255"`
+	Email     string `json:"email" form:"required,max=255,email"`
+	Password  string `json:"password" form:"required,max=255"`
+	FirstName string `json:"first_name" form:"required,max=255"`
+	LastName  string `json:"last_name" form:"required,max=255"`
 }
 
 type CreateUserResponse User

+ 4 - 0
dashboard/package.json

@@ -66,6 +66,10 @@
     "valtio": "^1.2.4",
     "zod": "^3.20.2"
   },
+  "resolutions": {
+    "@types/react": "16.14.0",
+    "@types/react-dom": "16.14.0"
+  },
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
     "start": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js",

+ 6 - 1
dashboard/src/main/auth/Register.tsx

@@ -61,7 +61,12 @@ const Register: React.FC<Props> = ({
       api
         .registerUser(
           "",
-          { email: email, password: password },
+          { 
+            email: email,
+            password: password,
+            first_name: firstName,
+            last_name: lastName,
+          },
           {}
         )
         .then((res: any) => {

+ 2 - 2
dashboard/src/main/home/Home.tsx

@@ -407,7 +407,7 @@ const Home: React.FC<Props> = props => {
           />
           {user?.isPorterUser || overrideInfraTabEnabled({
             projectID: currentProject?.id,
-          }) ? (
+          }) && (
             <Route
               path="/infrastructure"
               render={() => {
@@ -418,7 +418,7 @@ const Home: React.FC<Props> = props => {
                 );
               }}
             />
-          ) : null}
+          )}
           <Route
             path="/dashboard"
             render={() => {

+ 2 - 0
dashboard/src/shared/api.tsx

@@ -1393,6 +1393,8 @@ const logOutUser = baseApi("POST", "/api/logout");
 const registerUser = baseApi<{
   email: string;
   password: string;
+  first_name: string;
+  last_name: string;
 }>("POST", "/api/users");
 
 const rollbackChart = baseApi<

+ 3 - 0
internal/models/user.go

@@ -13,6 +13,9 @@ type User struct {
 	Password      string `json:"password"`
 	EmailVerified bool   `json:"email_verified"`
 
+	FirstName string `json:"first_name"`
+	LastName  string `json:"last_name"`
+
 	// ID of oauth integration for github connection (optional)
 	GithubAppIntegrationID uint