Skip to content

Commit

Permalink
refact: auth: overwrite email field (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
crlssn authored Dec 22, 2024
1 parent acc5010 commit 79a4e0d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/rpc/handlers/v1/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ var errInvalidEmail = errors.New("invalid email")
func (h *authHandler) Signup(ctx context.Context, req *connect.Request[apiv1.SignupRequest]) (*connect.Response[apiv1.SignupResponse], error) {
log := xcontext.MustExtractLogger(ctx)

emailAddress := strings.ReplaceAll(req.Msg.GetEmail(), " ", "")
if !strings.Contains(emailAddress, "@") {
req.Msg.Email = strings.ReplaceAll(req.Msg.GetEmail(), " ", "")
if !strings.Contains(req.Msg.GetEmail(), "@") {
log.Warn("invalid email")
return nil, connect.NewError(connect.CodeInvalidArgument, errInvalidEmail)
}
Expand All @@ -71,7 +71,7 @@ func (h *authHandler) Signup(ctx context.Context, req *connect.Request[apiv1.Sig
}

if err := h.repo.NewTx(ctx, func(tx repo.Tx) error {
auth, err := tx.CreateAuth(ctx, emailAddress, req.Msg.GetPassword())
auth, err := tx.CreateAuth(ctx, req.Msg.GetEmail(), req.Msg.GetPassword())
if err != nil {
if errors.Is(err, repo.ErrAuthEmailExists) {
log.Warn("email exists")
Expand Down

0 comments on commit 79a4e0d

Please sign in to comment.