From 35d59c75eb5fcfff8800b4f6399be97892df485d Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 20 Jan 2020 14:10:22 +1100 Subject: [PATCH] Password set, change and remove complete --- _locales/en/messages.json | 30 +++++++++++++ password_preload.js | 1 + preload.js | 7 ++- ts/components/session/SessionConfirm.tsx | 2 +- .../session/settings/SessionSettings.tsx | 44 +++++++++++++++++++ ts/global.d.ts | 1 + 6 files changed, 82 insertions(+), 3 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 9274247d5..2e1fb9c90 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2151,6 +2151,36 @@ "description": "Button action that the user can click to view their unique seed" }, + "setAccountPasswordTitle": { + "message": "Set Account Password", + "description": + "Prompt for user to set account password in settings view" + }, + "setAccountPasswordDescription": { + "message": "Secure your account and public key with a password", + "description": + "Description for set account password setting view" + }, + "changeAccountPasswordTitle": { + "message": "Change Account Password", + "description": + "Prompt for user to change account password in settings view" + }, + "changeAccountPasswordDescription": { + "message": "Change your password", + "description": + "Description for change account password setting view" + }, + "removeAccountPasswordTitle": { + "message": "Remove Account Password", + "description": + "Prompt for user to remove account password in settings view" + }, + "removeAccountPasswordDescription": { + "message": "Remove the password associated with your account", + "description": + "Description for remove account password setting view" + }, "showSeedPasswordRequest": { "message": "Please enter your password", "description": "Request for user to enter password to show seed." diff --git a/password_preload.js b/password_preload.js index 8d8a5b7de..f1673ce80 100644 --- a/password_preload.js +++ b/password_preload.js @@ -26,6 +26,7 @@ window.Signal = Signal.setup({ window.passwordUtil = require('./app/password_util'); + window.resetDatabase = () => { window.log.info('reset database'); ipcRenderer.send('resetDatabase'); diff --git a/preload.js b/preload.js index 3733966fa..528871baf 100644 --- a/preload.js +++ b/preload.js @@ -127,7 +127,6 @@ window.onUnblockNumber = number => ipc.send('on-unblock-number', number); ipc.on('mediaPermissionsChanged', () => { Whisper.events.trigger('mediaPermissionsChanged'); - W; }); ipc.on('on-unblock-number', (event, number) => { @@ -401,7 +400,6 @@ window.libphonenumber.PhoneNumberFormat = require('google-libphonenumber').Phone window.loadImage = require('blueimp-load-image'); window.getGuid = require('uuid/v4'); window.profileImages = require('./app/profile_images'); -window.passwordUtil = require('./app/password_util'); window.React = require('react'); window.ReactDOM = require('react-dom'); @@ -467,6 +465,11 @@ contextMenu({ }, }); +// User config for managing password DB entries etc. +const thisfaw = require('./app/password_util'); +console.log(thisfaw); + + // We pull this in last, because the native module involved appears to be sensitive to // /tmp mounted as noexec on Linux. require('./js/spell_check'); diff --git a/ts/components/session/SessionConfirm.tsx b/ts/components/session/SessionConfirm.tsx index 190193f0d..561f2127e 100644 --- a/ts/components/session/SessionConfirm.tsx +++ b/ts/components/session/SessionConfirm.tsx @@ -25,7 +25,7 @@ export class SessionConfirm extends React.Component { closeTheme: SessionButtonColor.Primary, hideCancel: false, }; -\ + constructor(props: any) { super(props); } diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index a1d1b1282..1747ed392 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { SettingsHeader } from './SessionSettingsHeader'; import { SessionSettingListItem } from './SessionSettingListItem'; +import { SessionButtonColor } from '../SessionButton'; export enum SessionSettingCategory { General = 'general', @@ -34,6 +35,9 @@ export class SettingsView extends React.Component { public renderSettingInCategory() { const { Settings } = window.Signal.Types; + //const hasPassword = window.userConfig.get('dbHasPassword'); + //console.log(`User has password: ${hasPassword}`); + // Grab initial values from database on startup // ID corresponds to instalGetter parameters in preload.js // They are NOT arbitrary; add with caution @@ -122,6 +126,7 @@ export class SettingsView extends React.Component { setFn: window.toggleMediaPermissions, content: {}, }, + { id: 'message-ttl', title: window.i18n('messageTTL'), @@ -132,6 +137,45 @@ export class SettingsView extends React.Component { setFn: undefined, content: {}, }, + { + id: 'set-password', + title: window.i18n('setAccountPasswordTitle'), + description: window.i18n('setAccountPasswordDescription'), + hidden: false, + type: SessionSettingType.Button, + category: SessionSettingCategory.Privacy, + setFn: undefined, + content: { + buttonText: window.i18n('setPassword'), + buttonColor: SessionButtonColor.Primary, + }, + }, + { + id: 'change-password', + title: window.i18n('changeAccountPasswordTitle'), + description: window.i18n('changeAccountPasswordDescription'), + hidden: false, + type: SessionSettingType.Button, + category: SessionSettingCategory.Privacy, + setFn: undefined, + content: { + buttonText: window.i18n('changePassword'), + buttonColor: SessionButtonColor.Primary, + }, + }, + { + id: 'remove-password', + title: window.i18n('removeAccountPasswordTitle'), + description: window.i18n('removeAccountPasswordDescription'), + hidden: false, + type: SessionSettingType.Button, + category: SessionSettingCategory.Privacy, + setFn: undefined, + content: { + buttonText: window.i18n('removePassword'), + buttonColor: SessionButtonColor.Danger, + }, + }, ]; return ( diff --git a/ts/global.d.ts b/ts/global.d.ts index 407c4ab23..37341f671 100644 --- a/ts/global.d.ts +++ b/ts/global.d.ts @@ -5,6 +5,7 @@ interface Window { mnemonic: any; clipboard: any; passwordUtil: any; + userConfig: any; dcodeIO: any; libsignal: any; libloki: any;