jottacloud: do not store username in config when using standard auth
Previously, with standard auth, the username would be stored in config - but only after
entering the non-standard device/mountpoint sequence during config (a feature introduced
with #5926). Regardless of that, rclone always requests the username from the api at
startup (NewFS).
In #6270 (commit 9dbed02329
) this was changed to always
store username in config (consistency), and then also use it to avoid the repeated
customer info request in NewFs (performance). But, as reported in #6309, it did not work
with legacy auth, where user enters username manually, if user entered an email address
instead of the internal username required for api requests. This change was therefore
recently reverted.
The current commit takes another step back to not store the username in config during
the non-standard device/mountpoint config sequence (consistentcy). The username will
now only be stored in config when using legacy auth, where it is an input parameter.
This commit is contained in:
parent
9f40cb114a
commit
72227a0151
1 changed files with 16 additions and 8 deletions
|
@ -284,7 +284,6 @@ sync or the backup section, for example, you must choose yes.`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m.Set(configUsername, cust.Username)
|
|
||||||
|
|
||||||
acc, err := getDriveInfo(ctx, jfsSrv, cust.Username)
|
acc, err := getDriveInfo(ctx, jfsSrv, cust.Username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -317,10 +316,14 @@ a new by entering a unique name.`, defaultDevice)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
jfsSrv := rest.NewClient(oAuthClient).SetRoot(jfsURL)
|
jfsSrv := rest.NewClient(oAuthClient).SetRoot(jfsURL)
|
||||||
|
apiSrv := rest.NewClient(oAuthClient).SetRoot(apiURL)
|
||||||
|
|
||||||
username, _ := m.Get(configUsername)
|
cust, err := getCustomerInfo(ctx, apiSrv)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
acc, err := getDriveInfo(ctx, jfsSrv, username)
|
acc, err := getDriveInfo(ctx, jfsSrv, cust.Username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -335,7 +338,7 @@ a new by entering a unique name.`, defaultDevice)
|
||||||
var dev *api.JottaDevice
|
var dev *api.JottaDevice
|
||||||
if isNew {
|
if isNew {
|
||||||
fs.Debugf(nil, "Creating new device: %s", device)
|
fs.Debugf(nil, "Creating new device: %s", device)
|
||||||
dev, err = createDevice(ctx, jfsSrv, path.Join(username, device))
|
dev, err = createDevice(ctx, jfsSrv, path.Join(cust.Username, device))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -343,7 +346,7 @@ a new by entering a unique name.`, defaultDevice)
|
||||||
m.Set(configDevice, device)
|
m.Set(configDevice, device)
|
||||||
|
|
||||||
if !isNew {
|
if !isNew {
|
||||||
dev, err = getDeviceInfo(ctx, jfsSrv, path.Join(username, device))
|
dev, err = getDeviceInfo(ctx, jfsSrv, path.Join(cust.Username, device))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -373,11 +376,16 @@ You may create a new by entering a unique name.`, device)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
jfsSrv := rest.NewClient(oAuthClient).SetRoot(jfsURL)
|
jfsSrv := rest.NewClient(oAuthClient).SetRoot(jfsURL)
|
||||||
|
apiSrv := rest.NewClient(oAuthClient).SetRoot(apiURL)
|
||||||
|
|
||||||
|
cust, err := getCustomerInfo(ctx, apiSrv)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
username, _ := m.Get(configUsername)
|
|
||||||
device, _ := m.Get(configDevice)
|
device, _ := m.Get(configDevice)
|
||||||
|
|
||||||
dev, err := getDeviceInfo(ctx, jfsSrv, path.Join(username, device))
|
dev, err := getDeviceInfo(ctx, jfsSrv, path.Join(cust.Username, device))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -395,7 +403,7 @@ You may create a new by entering a unique name.`, device)
|
||||||
return nil, fmt.Errorf("custom mountpoints not supported on built-in %s device: %w", defaultDevice, err)
|
return nil, fmt.Errorf("custom mountpoints not supported on built-in %s device: %w", defaultDevice, err)
|
||||||
}
|
}
|
||||||
fs.Debugf(nil, "Creating new mountpoint: %s", mountpoint)
|
fs.Debugf(nil, "Creating new mountpoint: %s", mountpoint)
|
||||||
_, err := createMountPoint(ctx, jfsSrv, path.Join(username, device, mountpoint))
|
_, err := createMountPoint(ctx, jfsSrv, path.Join(cust.Username, device, mountpoint))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue