From 3a2825d9eeae554e60d5e77f7c1a894a25ccef07 Mon Sep 17 00:00:00 2001 From: Daniel Joudat Date: Thu, 1 Jul 2021 19:39:17 +0300 Subject: [PATCH 1/2] added email format check (#175) --- user/handler/handler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/user/handler/handler.go b/user/handler/handler.go index 80c3c38..8e947e6 100644 --- a/user/handler/handler.go +++ b/user/handler/handler.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "encoding/base64" "fmt" + "regexp" "strings" "time" @@ -21,7 +22,8 @@ const ( ) var ( - alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + emailFormat = regexp.MustCompile("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$") ) func random(i int) string { @@ -47,6 +49,9 @@ func NewUser(db db.DbService) *User { } func (s *User) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.CreateResponse) error { + if !emailFormat.MatchString(req.Email) { + return errors.BadRequest("create.email-format-check", "email has wrong format") + } if len(req.Password) < 8 { return errors.InternalServerError("user.Create.Check", "Password is less than 8 characters") } From b8b915607dc4beab7ddf24a7249120032a91c9cc Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Fri, 2 Jul 2021 09:06:07 +0100 Subject: [PATCH 2/2] Update README.md --- currency/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/currency/README.md b/currency/README.md index 1d93c78..b9b81c4 100644 --- a/currency/README.md +++ b/currency/README.md @@ -2,7 +2,7 @@ Exchange rates and currency conversion # Currency Service -Real time currency conversion and exchange rates powered by [ExchangeRate-API](https://www.exchangerate-api.com/). +Real time currency conversion and exchange rates. Rate updates occur every 5 minutes. -Rate updates occur every 5 minutes. +Powered by [ExchangeRate-API](https://www.exchangerate-api.com/)