mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
Better user message about wrong mailbox password
This commit is contained in:
committed by
Jakub Cuth
parent
46bc8b08dc
commit
72c01046e3
@ -34,6 +34,9 @@ import (
|
||||
var (
|
||||
log = logrus.WithField("pkg", "users") //nolint[gochecknoglobals]
|
||||
isApplicationOutdated = false //nolint[gochecknoglobals]
|
||||
|
||||
// ErrWrongMailboxPassword is returned when login password is OK but not the mailbox one.
|
||||
ErrWrongMailboxPassword = errors.New("wrong mailbox password")
|
||||
)
|
||||
|
||||
// Users is a struct handling users.
|
||||
@ -332,27 +335,27 @@ func getAPIUser(client pmapi.Client, mbPassphrase string) (user *pmapi.User, has
|
||||
salt, err := client.AuthSalt()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not get salt")
|
||||
return
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
hashedPassphrase, err = pmapi.HashMailboxPassword(mbPassphrase, salt)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not hash mailbox password")
|
||||
return
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
// We unlock the user's PGP key here to detect if the user's mailbox password is wrong.
|
||||
if err = client.Unlock([]byte(hashedPassphrase)); err != nil {
|
||||
log.WithError(err).Error("Wrong mailbox password")
|
||||
return
|
||||
return nil, "", ErrWrongMailboxPassword
|
||||
}
|
||||
|
||||
if user, err = client.CurrentUser(); err != nil {
|
||||
log.WithError(err).Error("Could not load user data")
|
||||
return
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return
|
||||
return user, hashedPassphrase, nil
|
||||
}
|
||||
|
||||
// GetUsers returns all added users into keychain (even logged out users).
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
package users
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/events"
|
||||
@ -26,6 +25,7 @@ import (
|
||||
"github.com/ProtonMail/proton-bridge/internal/users/credentials"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -33,19 +33,18 @@ func TestUsersFinishLoginBadMailboxPassword(t *testing.T) {
|
||||
m := initMocks(t)
|
||||
defer m.ctrl.Finish()
|
||||
|
||||
err := errors.New("bad password")
|
||||
gomock.InOrder(
|
||||
// Init users with no user from keychain.
|
||||
m.credentialsStore.EXPECT().List().Return([]string{}, nil),
|
||||
|
||||
// Set up mocks for FinishLogin.
|
||||
m.pmapiClient.EXPECT().AuthSalt().Return("", nil),
|
||||
m.pmapiClient.EXPECT().Unlock([]byte(testCredentials.MailboxPassword)).Return(err),
|
||||
m.pmapiClient.EXPECT().Unlock([]byte(testCredentials.MailboxPassword)).Return(errors.New("no keys could be unlocked")),
|
||||
m.pmapiClient.EXPECT().DeleteAuth(),
|
||||
m.pmapiClient.EXPECT().Logout(),
|
||||
)
|
||||
|
||||
checkUsersFinishLogin(t, m, testAuth, testCredentials.MailboxPassword, "", err)
|
||||
checkUsersFinishLogin(t, m, testAuth, testCredentials.MailboxPassword, "", ErrWrongMailboxPassword)
|
||||
}
|
||||
|
||||
func refreshWithToken(token string) *pmapi.Auth {
|
||||
|
||||
@ -10,6 +10,7 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
||||
|
||||
### Changed
|
||||
* GODT-885 Do not explicitly unlabel folders during move to match behaviour of other clients.
|
||||
* GODT-616 Better user message about wrong mailbox password.
|
||||
|
||||
### Fixed
|
||||
* GODT-1011 Stable integration test deleting many messages using UID EXPUNGE.
|
||||
|
||||
Reference in New Issue
Block a user