From f40d9deaa11c2b9a941c9474f61957c5f9786fb8 Mon Sep 17 00:00:00 2001 From: slaventius Date: Wed, 1 Feb 2023 14:03:36 +0300 Subject: [PATCH] * --- internal/transport/grpc/grpc.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/internal/transport/grpc/grpc.go b/internal/transport/grpc/grpc.go index 908e3e3..796ed34 100644 --- a/internal/transport/grpc/grpc.go +++ b/internal/transport/grpc/grpc.go @@ -70,29 +70,21 @@ func (s *authDBServer) Registration(ctx context.Context, req *api.RegistrationRe defer s.mu.Unlock() // - val, ok := s.users[req.GetLogin()] - if ok { - user := &api.RegistrationResponse{ - Code: val.Code, - Email: val.Email, - } - - return user, errors.New("login already registered") + if _, ok := s.users[req.GetLogin()]; ok { + return nil, errors.New("login already registered") } // s.id = s.id + 1 - - // - id := time.Now().Nanosecond() - code := strconv.Itoa(id / 2) + unique := time.Now().Nanosecond() + code := strconv.Itoa(unique / 2) // s.users[req.Login] = &user{ ID: s.id, Code: code, Login: req.Login, - Password: strconv.Itoa(id), + Password: strconv.Itoa(unique), Email: req.Email, Confirmed: false, }