forked from Silverfish/proton-bridge
GODT-2173: fix: Migrate Bridge password from v2.X.
This commit is contained in:
@ -34,13 +34,11 @@ func getKeychainPrefPath(vaultDir string) string {
|
||||
}
|
||||
|
||||
func GetHelper(vaultDir string) (string, error) {
|
||||
filePath := getKeychainPrefPath(vaultDir)
|
||||
|
||||
if _, err := os.Stat(filePath); errors.Is(err, fs.ErrNotExist) {
|
||||
if _, err := os.Stat(getKeychainPrefPath(vaultDir)); errors.Is(err, fs.ErrNotExist) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
b, err := os.ReadFile(filePath)
|
||||
b, err := os.ReadFile(getKeychainPrefPath(vaultDir))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ type UserData struct {
|
||||
GluonKey []byte
|
||||
GluonIDs map[string]string
|
||||
UIDValidity map[string]imap.UID
|
||||
BridgePass []byte
|
||||
BridgePass []byte // raw token represented as byte slice (needs to be encoded)
|
||||
AddressMode AddressMode
|
||||
|
||||
AuthUID string
|
||||
|
||||
@ -99,11 +99,18 @@ func (user *User) SetAddressMode(mode AddressMode) error {
|
||||
})
|
||||
}
|
||||
|
||||
// BridgePass returns the user's bridge password (unencoded).
|
||||
// BridgePass returns the user's bridge password as raw token bytes (unencoded).
|
||||
func (user *User) BridgePass() []byte {
|
||||
return user.vault.getUser(user.userID).BridgePass
|
||||
}
|
||||
|
||||
// SetBridgePass saves bridge password as raw token bytes (unecoded).
|
||||
func (user *User) SetBridgePass(newPass []byte) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.BridgePass = newPass
|
||||
})
|
||||
}
|
||||
|
||||
// AuthUID returns the user's auth UID.
|
||||
func (user *User) AuthUID() string {
|
||||
return user.vault.getUser(user.userID).AuthUID
|
||||
|
||||
Reference in New Issue
Block a user