|
|
|
@ -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") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|