slaventius 2 years ago
parent 4fee6063a0
commit 8695307a45
  1. 2
      .vscode/launch.json
  2. 21
      internal/transport/grpc/grpc.go

@ -13,7 +13,7 @@
"env": { "env": {
// "DB_HOST": "127.0.0.1", // "DB_HOST": "127.0.0.1",
// "DB_PORT":"9055", // "DB_PORT":"9055",
"APP_PORT":"9056", "APP_PORT":"9995",
}, },
"args": [] "args": []
} }

@ -41,17 +41,23 @@ func (s *authDBServer) Login(ctx context.Context, req *api.LoginRequest) (*api.L
// //
user, ok := s.users[req.GetLogin()] user, ok := s.users[req.GetLogin()]
if !ok { if !ok {
return nil, errors.New("login unknown") return &api.LoginResponse{
ID: 0,
}, errors.New("login unknown")
} }
// //
if !user.Confirmed { if !user.Confirmed {
return nil, errors.New("login unconfirmed") return &api.LoginResponse{
ID: 0,
}, errors.New("login unconfirmed")
} }
// //
if user.Password != req.Password { if user.Password != req.Password {
return nil, errors.New("password incorrect") return &api.LoginResponse{
ID: 0,
}, errors.New("password incorrect")
} }
return &api.LoginResponse{ return &api.LoginResponse{
@ -64,9 +70,14 @@ func (s *authDBServer) Registration(ctx context.Context, req *api.RegistrationRe
defer s.mu.Unlock() defer s.mu.Unlock()
// //
_, ok := s.users[req.GetLogin()] val, ok := s.users[req.GetLogin()]
if ok { 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")
} }
// //

Loading…
Cancel
Save