|
|
|
@ -14,6 +14,7 @@ import ( |
|
|
|
|
|
|
|
|
|
"git.slaventius.ru/test3k/authDB/internal/config" |
|
|
|
|
api "git.slaventius.ru/test3k/umate/pkg/api" |
|
|
|
|
apiKafka "git.slaventius.ru/test3k/umate/pkg/kafka" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
type user struct { |
|
|
|
@ -22,7 +23,7 @@ type user struct { |
|
|
|
|
Password string |
|
|
|
|
Confirmed bool |
|
|
|
|
Time time.Time |
|
|
|
|
msg |
|
|
|
|
apiKafka.MessageRegistration |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type AuthDBServer struct { |
|
|
|
@ -38,7 +39,7 @@ func NewServer(ctx context.Context, config *config.Config) *AuthDBServer { |
|
|
|
|
return &AuthDBServer{ |
|
|
|
|
mu: sync.Mutex{}, |
|
|
|
|
users: make(map[string]*user), |
|
|
|
|
kafkaWriter: kafka.NewWriter(ctx, topicRegistrations, net.JoinHostPort(config.Kafka.Host, strconv.Itoa(config.Kafka.Port))), |
|
|
|
|
kafkaWriter: kafka.NewWriter(ctx, apiKafka.TopicRegistrations, net.JoinHostPort(config.Kafka.Host, strconv.Itoa(config.Kafka.Port))), |
|
|
|
|
ctx: ctx, |
|
|
|
|
id: 0, |
|
|
|
|
} |
|
|
|
@ -93,20 +94,20 @@ func (s *AuthDBServer) Registration(ctx context.Context, req *api.RegistrationRe |
|
|
|
|
Password: req.GetPassword(), |
|
|
|
|
Confirmed: false, |
|
|
|
|
Time: time.Now().Add(time.Minute * 15), |
|
|
|
|
msg: msg{ |
|
|
|
|
MessageRegistration: apiKafka.MessageRegistration{ |
|
|
|
|
Code: strconv.Itoa(time.Now().Nanosecond()), |
|
|
|
|
Email: req.GetEmail(), |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
value, eru := json.Marshal(user.msg) |
|
|
|
|
value, eru := json.Marshal(user.MessageRegistration) |
|
|
|
|
if eru != nil { |
|
|
|
|
return nil, eru |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
log.Printf("publication code %s to %s ...", user.msg.Code, user.msg.Email) |
|
|
|
|
log.Printf("publication code %s to %s ...", user.MessageRegistration.Code, user.MessageRegistration.Email) |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
err := s.kafkaWriter.WriteMessage([]byte(user.Login), value) |
|
|
|
@ -119,11 +120,11 @@ func (s *AuthDBServer) Registration(ctx context.Context, req *api.RegistrationRe |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
log.Printf("publication code %s to %s completed", user.msg.Code, user.msg.Email) |
|
|
|
|
log.Printf("publication code %s to %s completed", user.MessageRegistration.Code, user.MessageRegistration.Email) |
|
|
|
|
|
|
|
|
|
return &api.RegistrationResponse{ |
|
|
|
|
Code: user.msg.Code, |
|
|
|
|
Email: user.msg.Email, |
|
|
|
|
Code: user.MessageRegistration.Code, |
|
|
|
|
Email: user.MessageRegistration.Email, |
|
|
|
|
}, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|