mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 13:16:53 +00:00
feat(GODT-2801): Identity State Cloning & Auth Check
This patch moves the `user.User.CheckAuth` function into the `State` type as it contains all the necessary information to perform this check. A couple of more interfaces are added to abstract the retrieval of the Bridge and the User's key passwords, as well as telemetry reports. Finally, adds `State.OnAddressEvents` which other services should use to update the state.
This commit is contained in:
@ -51,33 +51,25 @@ type Service struct {
|
||||
}
|
||||
|
||||
func NewService(
|
||||
ctx context.Context,
|
||||
service userevents.Subscribable,
|
||||
user proton.User,
|
||||
eventPublisher events.EventPublisher,
|
||||
provider IdentityProvider,
|
||||
) (*Service, error) {
|
||||
addresses, err := provider.GetAddresses(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get addresses: %w", err)
|
||||
}
|
||||
|
||||
subscriberName := fmt.Sprintf("identity-%v", user.ID)
|
||||
state *State,
|
||||
) *Service {
|
||||
subscriberName := fmt.Sprintf("identity-%v", state.User.ID)
|
||||
|
||||
return &Service{
|
||||
eventService: service,
|
||||
identity: NewState(user, addresses, provider),
|
||||
identity: *state,
|
||||
eventPublisher: eventPublisher,
|
||||
log: logrus.WithFields(logrus.Fields{
|
||||
"service": "user-identity",
|
||||
"user": user.ID,
|
||||
"user": state.User.ID,
|
||||
}),
|
||||
|
||||
userSubscriber: userevents.NewUserSubscriber(subscriberName),
|
||||
refreshSubscriber: userevents.NewRefreshSubscriber(subscriberName),
|
||||
addressSubscriber: userevents.NewAddressSubscriber(subscriberName),
|
||||
usedSpaceSubscriber: userevents.NewUserUsedSpaceSubscriber(subscriberName),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) Start(group *async.Group) {
|
||||
|
||||
Reference in New Issue
Block a user