config: allow storing credentials for email address

When configuring a WebDAV server with username = email address and no
URL (which is possible if the server supports service discovery via
the domain in the email address), then storing the credentials in the
GNOME keyring used to fail with "cannot store password in GNOME
keyring, not enough attributes".

That is because GNOME keyring seemed to get confused when a network
login has no server name and some extra safeguards were added to
SyncEvolution to avoid this.

To store the credentials in the case above, the email address now gets
split into user and domain part and together get used to look up the
password.
This commit is contained in:
Patrick Ohly 2014-07-23 20:21:14 +02:00
parent 76599a8056
commit 57f44fe607
1 changed files with 11 additions and 0 deletions

View File

@ -1402,6 +1402,17 @@ public:
}
}
key.user = getUsername(syncPropUsername, globalConfigNode);
// User domain part of a username which looks like an email address
// as server name if we don't have something better. Needed for
// WebDAV configs using just an email address to locate the server.
if (key.server.empty()) {
size_t offset = key.user.find('@');
if (offset != key.user.npos &&
offset != key.user.size() - 1) {
key.server = key.user.substr(offset + 1);
key.user.resize(offset);
}
}
return key;
}
} syncPropPassword;