Skip to content

Commit

Permalink
include email_verified & remove names from auth req body
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu committed Dec 3, 2024
1 parent 5a12ea0 commit d5c75ea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
12 changes: 6 additions & 6 deletions backend/internal/server/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ func (s *Server) handleSignup(c echo.Context) error {
user, err := s.queries.CreateUser(ctx, db.CreateUserParams{
Email: req.Email,
PasswordHash: string(hashedPassword),
FirstName: &req.FirstName,
LastName: &req.LastName,
Role: req.Role,
})
if err != nil {
Expand All @@ -65,10 +63,11 @@ func (s *Server) handleSignup(c echo.Context) error {
User: User{
ID: user.ID,
Email: user.Email,
FirstName: *user.FirstName,
LastName: *user.LastName,
FirstName: user.FirstName,
LastName: user.LastName,
Role: user.Role,
WalletAddress: user.WalletAddress,
EmailVerified: user.EmailVerified,
},
})
}
Expand Down Expand Up @@ -103,10 +102,11 @@ func (s *Server) handleSignin(c echo.Context) error {
User: User{
ID: user.ID,
Email: user.Email,
FirstName: *user.FirstName,
LastName: *user.LastName,
FirstName: user.FirstName,
LastName: user.LastName,
Role: user.Role,
WalletAddress: user.WalletAddress,
EmailVerified: user.EmailVerified,
},
})
}
Expand Down
16 changes: 6 additions & 10 deletions backend/internal/server/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ func TestAuth(t *testing.T) {
// test signup
t.Run("signup", func(t *testing.T) {
payload := SignupRequest{
Email: "[email protected]",
Password: "password123",
FirstName: "Test",
LastName: "User",
Role: "startup_owner",
Email: "[email protected]",
Password: "password123",
Role: "startup_owner",
}
body, _ := json.Marshal(payload)

Expand All @@ -66,11 +64,9 @@ func TestAuth(t *testing.T) {
// test duplicate email
t.Run("duplicate email", func(t *testing.T) {
payload := SignupRequest{
Email: "[email protected]",
Password: "password123",
FirstName: "Test",
LastName: "User",
Role: "startup_owner",
Email: "[email protected]",
Password: "password123",
Role: "startup_owner",
}
body, _ := json.Marshal(payload)

Expand Down
13 changes: 6 additions & 7 deletions backend/internal/server/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ type CreateResourceRequestRequest struct {
}

type SignupRequest struct {
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,min=8"`
FirstName string `json:"first_name" validate:"required"`
LastName string `json:"last_name" validate:"required"`
Role db.UserRole `json:"role" validate:"required,valid_user_role,non_admin_role"`
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,min=8"`
Role db.UserRole `json:"role" validate:"required,valid_user_role,non_admin_role"`
}

type SigninRequest struct {
Expand All @@ -65,10 +63,11 @@ type AuthResponse struct {
type User struct {
ID string `json:"id"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
FirstName *string `json:"first_name"`
LastName *string `json:"last_name"`
Role db.UserRole `json:"role"`
WalletAddress *string `json:"wallet_address,omitempty"`
EmailVerified bool `json:"email_verified"`
}

type CreateCompanyFinancialsRequest struct {
Expand Down

0 comments on commit d5c75ea

Please sign in to comment.