Merge ac2f03c8235cdc1c1f5187aa5eef8179b0bde662 into 0b9671313b14ffe839ecbd7dd2ae5ac7f6f05db8

This commit is contained in:
Salvatore Gabriele La Greca 2025-04-13 19:59:21 -03:00 committed by GitHub
commit d79269d7a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,6 +68,10 @@ func init() {
Help: "Password.",
Required: true,
IsPassword: true,
}, {
Name: "mfac",
Help: "Multi-factor authentication code.",
Required: false,
}, {
Name: "debug",
Help: `Output more debug from Mega.
@ -111,6 +115,7 @@ Enabling it will increase CPU usage and add network overhead.`,
type Options struct {
User string `config:"user"`
Pass string `config:"pass"`
MFAC string `config:"mfac"`
Debug bool `config:"debug"`
HardDelete bool `config:"hard_delete"`
UseHTTPS bool `config:"use_https"`
@ -228,7 +233,14 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
})
}
err := srv.Login(opt.User, opt.Pass)
// Login to mega
if opt.MFAC != "" {
// Login with MFA if set in the config by the user
err = srv.MultiFactorLogin(opt.User, opt.Pass, opt.MFAC)
} else {
err = srv.Login(opt.User, opt.Pass)
}
if err != nil {
return nil, fmt.Errorf("couldn't login: %w", err)
}