Skip to content

Commit

Permalink
feat: use caller email if user email is missing in payload
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanarya0 committed Jul 29, 2024
1 parent 82980f5 commit f73ea65
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/api/v1beta1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ func (h Handler) CreateUser(ctx context.Context, request *shieldv1beta1.CreateUs
return nil, grpcBadBodyError
}

currentUserEmail, ok := user.GetEmailFromContext(ctx)
if !ok {
return nil, grpcUnauthenticated
}

email := strings.TrimSpace(request.GetBody().GetEmail())
if email == "" {
return nil, grpcBadBodyError
email = currentUserEmail
}
if !isValidEmail(email) {
return nil, user.ErrInvalidEmail
Expand Down

0 comments on commit f73ea65

Please sign in to comment.