mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
If askForOptionalPassword is enabled preset a random password
This is the same approach used on the server side. Turns out I quite like it, this avoids popping up a dialog to the user and since she won't know the password she'll have to set a new one anyway or disable it. Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
parent
099d25a56c
commit
e78312f094
1 changed files with 18 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "configfile.h"
|
||||
#include "theme.h"
|
||||
#include "thumbnailjob.h"
|
||||
#include "wordlist.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFileIconProvider>
|
||||
|
@ -33,6 +34,20 @@
|
|||
#include <QPushButton>
|
||||
#include <QFrame>
|
||||
|
||||
namespace {
|
||||
QString createRandomPassword()
|
||||
{
|
||||
const auto words = OCC::WordList::getRandomWords(10);
|
||||
|
||||
const auto addFirstLetter = [](const QString ¤t, const QString &next) {
|
||||
return current + next.at(0);
|
||||
};
|
||||
|
||||
return std::accumulate(std::cbegin(words), std::cend(words), QString(), addFirstLetter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace OCC {
|
||||
|
||||
static const int thumbnailSize = 40;
|
||||
|
@ -303,7 +318,9 @@ void ShareDialog::showSharingUi()
|
|||
void ShareDialog::slotCreateLinkShare()
|
||||
{
|
||||
if(_manager) {
|
||||
_manager->createLinkShare(_sharePath, QString(), QString());
|
||||
const auto askOptionalPassword = _accountState->account()->capabilities().sharePublicLinkAskOptionalPassword();
|
||||
const auto password = askOptionalPassword ? createRandomPassword() : QString();
|
||||
_manager->createLinkShare(_sharePath, QString(), password);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue