From 8695307a455738d235e79b546bb85c3a7c594f7d Mon Sep 17 00:00:00 2001 From: slaventius Date: Wed, 1 Feb 2023 13:54:41 +0300 Subject: [PATCH] * --- .vscode/launch.json | 2 +- internal/transport/grpc/grpc.go | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index a5379fb..c6f7343 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,7 @@ "env": { // "DB_HOST": "127.0.0.1", // "DB_PORT":"9055", - "APP_PORT":"9056", + "APP_PORT":"9995", }, "args": [] } diff --git a/internal/transport/grpc/grpc.go b/internal/transport/grpc/grpc.go index e278262..908e3e3 100644 --- a/internal/transport/grpc/grpc.go +++ b/internal/transport/grpc/grpc.go @@ -41,17 +41,23 @@ func (s *authDBServer) Login(ctx context.Context, req *api.LoginRequest) (*api.L // user, ok := s.users[req.GetLogin()] if !ok { - return nil, errors.New("login unknown") + return &api.LoginResponse{ + ID: 0, + }, errors.New("login unknown") } // if !user.Confirmed { - return nil, errors.New("login unconfirmed") + return &api.LoginResponse{ + ID: 0, + }, errors.New("login unconfirmed") } // if user.Password != req.Password { - return nil, errors.New("password incorrect") + return &api.LoginResponse{ + ID: 0, + }, errors.New("password incorrect") } return &api.LoginResponse{ @@ -64,9 +70,14 @@ func (s *authDBServer) Registration(ctx context.Context, req *api.RegistrationRe defer s.mu.Unlock() // - _, ok := s.users[req.GetLogin()] + val, ok := s.users[req.GetLogin()] if ok { - return nil, errors.New("login already registered") + user := &api.RegistrationResponse{ + Code: val.Code, + Email: val.Email, + } + + return user, errors.New("login already registered") } //