Merge pull request #13870 from zfox23/wallet_autologout

Implement Wallet Security feature - Auto Logout checkbox
This commit is contained in:
Howard Stearns 2018-08-23 18:04:38 -07:00 committed by GitHub
commit 9a472fa388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 0 deletions

View file

@ -120,6 +120,7 @@ Item {
TextField {
id: usernameField
text: Settings.getValue("wallet/savedUsername", "");
width: parent.width
focus: true
label: "Username or Email"

View file

@ -140,6 +140,81 @@ Item {
}
}
}
Item {
id: autoLogoutContainer;
anchors.top: changeSecurityImageContainer.bottom;
anchors.topMargin: 8;
anchors.left: parent.left;
anchors.leftMargin: 40;
anchors.right: parent.right;
anchors.rightMargin: 55;
height: 75;
HiFiGlyphs {
id: autoLogoutImage;
text: hifi.glyphs.walletKey;
// Size
size: 80;
// Anchors
anchors.top: parent.top;
anchors.topMargin: 20;
anchors.left: parent.left;
// Style
color: hifi.colors.white;
}
HifiControlsUit.CheckBox {
id: autoLogoutCheckbox;
checked: Settings.getValue("wallet/autoLogout", false);
text: "Automatically Log Out when Exiting Interface"
// Anchors
anchors.verticalCenter: autoLogoutImage.verticalCenter;
anchors.left: autoLogoutImage.right;
anchors.leftMargin: 20;
anchors.right: autoLogoutHelp.left;
anchors.rightMargin: 12;
boxSize: 28;
labelFontSize: 18;
color: hifi.colors.white;
onCheckedChanged: {
Settings.setValue("wallet/autoLogout", checked);
if (checked) {
Settings.setValue("wallet/savedUsername", Account.username);
} else {
Settings.setValue("wallet/savedUsername", "");
}
}
}
RalewaySemiBold {
id: autoLogoutHelp;
text: '[?]';
// Anchors
anchors.verticalCenter: autoLogoutImage.verticalCenter;
anchors.right: parent.right;
width: 30;
height: 30;
// Text size
size: 18;
// Style
color: hifi.colors.blueHighlight;
MouseArea {
anchors.fill: parent;
hoverEnabled: true;
onEntered: {
parent.color = hifi.colors.blueAccent;
}
onExited: {
parent.color = hifi.colors.blueHighlight;
}
onClicked: {
sendSignalToWallet({method: 'walletSecurity_autoLogoutHelp'});
}
}
}
}
}
//

View file

@ -382,6 +382,17 @@ Rectangle {
} else if (msg.method === 'walletSecurity_changeSecurityImage') {
securityImageChange.initModel();
root.activeView = "securityImageChange";
} else if (msg.method === 'walletSecurity_autoLogoutHelp') {
lightboxPopup.titleText = "Automatically Log Out";
lightboxPopup.bodyText = "By default, after you log in to High Fidelity, you will stay logged in to your High Fidelity " +
"account even after you close and re-open Interface. This means anyone who opens Interface on your computer " +
"could make purchases with your Wallet.\n\n" +
"If you do not want to stay logged in across Interface sessions, check this box.";
lightboxPopup.button1text = "CLOSE";
lightboxPopup.button1method = function() {
lightboxPopup.visible = false;
}
lightboxPopup.visible = true;
}
}
}

View file

@ -375,6 +375,7 @@ static const int INTERVAL_TO_CHECK_HMD_WORN_STATUS = 500; // milliseconds
static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop";
static const QString ACTIVE_DISPLAY_PLUGIN_SETTING_NAME = "activeDisplayPlugin";
static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
static const QString AUTO_LOGOUT_SETTING_NAME = "wallet/autoLogout";
const std::vector<std::pair<QString, Application::AcceptURLMethod>> Application::_acceptedExtensions {
{ SVO_EXTENSION, &Application::importSVOFromURL },
@ -1730,6 +1731,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
QTimer* settingsTimer = new QTimer();
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer]{
bool autoLogout = Setting::Handle<bool>(AUTO_LOGOUT_SETTING_NAME, false).get();
if (autoLogout) {
auto accountManager = DependencyManager::get<AccountManager>();
accountManager->logout();
}
// Disconnect the signal from the save settings
QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
// Stop the settings timer

View file

@ -406,6 +406,11 @@
sendMoneyRecipient = null;
}
function onUsernameChanged() {
Settings.setValue("wallet/autoLogout", false);
Settings.setValue("wallet/savedUsername", "");
}
// Function Name: fromQml()
//
// Description:
@ -581,6 +586,7 @@
var tablet = null;
var walletEnabled = Settings.getValue("commerce", true);
function startup() {
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
if (walletEnabled) {
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
button = tablet.addButton({
@ -612,6 +618,7 @@
removeOverlays();
}
function shutdown() {
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
button.clicked.disconnect(onButtonClicked);
tablet.removeButton(button);
deleteSendMoneyParticleEffect();