Remove case sensitivity from emails

This commit is contained in:
Ben Toogood
2021-02-18 12:11:44 +00:00
parent 7932fdbe38
commit eef581b94c
2 changed files with 4 additions and 4 deletions

View File

@@ -64,7 +64,7 @@ func (i *Invites) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.Cre
ID: uuid.New().String(), ID: uuid.New().String(),
Code: generateCode(), Code: generateCode(),
GroupID: req.GroupId, GroupID: req.GroupId,
Email: req.Email, Email: strings.ToLower(req.Email),
} }
if err := i.DB.Create(invite).Error; err != nil && strings.Contains(err.Error(), "group_email") { if err := i.DB.Create(invite).Error; err != nil && strings.Contains(err.Error(), "group_email") {
} else if err != nil { } else if err != nil {
@@ -116,7 +116,7 @@ func (i *Invites) List(ctx context.Context, req *pb.ListRequest, rsp *pb.ListRes
query.GroupID = req.GroupId.Value query.GroupID = req.GroupId.Value
} }
if req.Email != nil { if req.Email != nil {
query.Email = req.Email.Value query.Email = strings.ToLower(req.Email.Value)
} }
// query the database // query the database

View File

@@ -97,7 +97,7 @@ func (u *Users) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.Creat
ID: uuid.New().String(), ID: uuid.New().String(),
FirstName: req.FirstName, FirstName: req.FirstName,
LastName: req.LastName, LastName: req.LastName,
Email: req.Email, Email: strings.ToLower(req.Email),
Password: phash, Password: phash,
} }
err = u.DB.Create(user).Error err = u.DB.Create(user).Error
@@ -184,7 +184,7 @@ func (u *Users) Update(ctx context.Context, req *pb.UpdateRequest, rsp *pb.Updat
user.LastName = req.LastName.Value user.LastName = req.LastName.Value
} }
if req.Email != nil { if req.Email != nil {
user.Email = req.Email.Value user.Email = strings.ToLower(req.Email.Value)
} }
// write the user to the database // write the user to the database