feat(GODT-2714): Apply PR comments.

This commit is contained in:
Romain LE JEUNE
2023-06-29 09:54:42 +02:00
parent 720f662afe
commit c43739a7ef
3 changed files with 10 additions and 5 deletions

View File

@ -297,12 +297,12 @@ func (bridge *Bridge) SetColorScheme(colorScheme string) error {
// Note: it does not clear the keychain. The only entry in the keychain is the vault password, // Note: it does not clear the keychain. The only entry in the keychain is the vault password,
// which we need at next startup to decrypt the vault. // which we need at next startup to decrypt the vault.
func (bridge *Bridge) FactoryReset(ctx context.Context) { func (bridge *Bridge) FactoryReset(ctx context.Context) {
telemetry := bridge.IsTelemetryAvailable() useTelemetry := bridge.IsTelemetryAvailable()
// Delete all the users. // Delete all the users.
safe.Lock(func() { safe.Lock(func() {
for _, user := range bridge.users { for _, user := range bridge.users {
bridge.logoutUser(ctx, user, true, true, telemetry) bridge.logoutUser(ctx, user, true, true, useTelemetry)
} }
}, bridge.usersLock) }, bridge.usersLock)

View File

@ -72,7 +72,12 @@ func (s *smtpSession) AuthPlain(username, password string) error {
}).Error("Incorrect login credentials.") }).Error("Incorrect login credentials.")
err := fmt.Errorf("invalid username or password") err := fmt.Errorf("invalid username or password")
for _, user := range s.users { for _, user := range s.users {
for _, mail := range user.Emails() {
if mail == username {
user.ReportConfigStatusFailure(err.Error()) user.ReportConfigStatusFailure(err.Error())
return err
}
}
} }
return err return err
}, s.usersLock) }, s.usersLock)

View File

@ -243,7 +243,7 @@ func (bridge *Bridge) LogoutUser(ctx context.Context, userID string) error {
func (bridge *Bridge) DeleteUser(ctx context.Context, userID string) error { func (bridge *Bridge) DeleteUser(ctx context.Context, userID string) error {
logrus.WithField("userID", userID).Info("Deleting user") logrus.WithField("userID", userID).Info("Deleting user")
telemetry := bridge.IsTelemetryAvailable() useTelemetry := bridge.IsTelemetryAvailable()
return safe.LockRet(func() error { return safe.LockRet(func() error {
if !bridge.vault.HasUser(userID) { if !bridge.vault.HasUser(userID) {
@ -251,7 +251,7 @@ func (bridge *Bridge) DeleteUser(ctx context.Context, userID string) error {
} }
if user, ok := bridge.users[userID]; ok { if user, ok := bridge.users[userID]; ok {
bridge.logoutUser(ctx, user, true, true, telemetry) bridge.logoutUser(ctx, user, true, true, useTelemetry)
} }
if err := bridge.vault.DeleteUser(userID); err != nil { if err := bridge.vault.DeleteUser(userID); err != nil {