diff options
author | 2020-05-03 16:07:02 +0200 | |
---|---|---|
committer | 2020-05-03 16:07:02 +0200 | |
commit | 2f28ec495d5ba2f9368020391dd52da16ed008cd (patch) | |
tree | b49b8186c578140bb860c5bf95c0177757b16178 /src/containers | |
parent | Create SECURITY.md (#705) (diff) | |
download | ferdium-app-2f28ec495d5ba2f9368020391dd52da16ed008cd.tar.gz ferdium-app-2f28ec495d5ba2f9368020391dd52da16ed008cd.tar.zst ferdium-app-2f28ec495d5ba2f9368020391dd52da16ed008cd.zip |
Add password hashing to lock password (#694)
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/auth/LockedScreen.js | 4 | ||||
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/containers/auth/LockedScreen.js b/src/containers/auth/LockedScreen.js index 8f6ce85c3..a04107072 100644 --- a/src/containers/auth/LockedScreen.js +++ b/src/containers/auth/LockedScreen.js | |||
@@ -4,6 +4,8 @@ import { inject, observer } from 'mobx-react'; | |||
4 | import Locked from '../../components/auth/Locked'; | 4 | import Locked from '../../components/auth/Locked'; |
5 | import SettingsStore from '../../stores/SettingsStore'; | 5 | import SettingsStore from '../../stores/SettingsStore'; |
6 | 6 | ||
7 | import { hash } from '../../helpers/password-helpers'; | ||
8 | |||
7 | export default @inject('stores', 'actions') @observer class LockedScreen extends Component { | 9 | export default @inject('stores', 'actions') @observer class LockedScreen extends Component { |
8 | state = { | 10 | state = { |
9 | error: false, | 11 | error: false, |
@@ -24,7 +26,7 @@ export default @inject('stores', 'actions') @observer class LockedScreen extends | |||
24 | correctPassword = ''; | 26 | correctPassword = ''; |
25 | } | 27 | } |
26 | 28 | ||
27 | if (String(password) === String(correctPassword)) { | 29 | if (hash(String(password)) === String(correctPassword)) { |
28 | this.props.actions.settings.update({ | 30 | this.props.actions.settings.update({ |
29 | type: 'app', | 31 | type: 'app', |
30 | data: { | 32 | data: { |
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index f6c2d4360..3dba3bc11 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -16,6 +16,7 @@ import { | |||
16 | import { config as spellcheckerConfig } from '../../features/spellchecker'; | 16 | import { config as spellcheckerConfig } from '../../features/spellchecker'; |
17 | 17 | ||
18 | import { getSelectOptions } from '../../helpers/i18n-helpers'; | 18 | import { getSelectOptions } from '../../helpers/i18n-helpers'; |
19 | import { hash } from '../../helpers/password-helpers'; | ||
19 | 20 | ||
20 | import EditSettingsForm from '../../components/settings/settings/EditSettingsForm'; | 21 | import EditSettingsForm from '../../components/settings/settings/EditSettingsForm'; |
21 | import ErrorBoundary from '../../components/util/ErrorBoundary'; | 22 | import ErrorBoundary from '../../components/util/ErrorBoundary'; |
@@ -185,6 +186,14 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
185 | intl: intlShape, | 186 | intl: intlShape, |
186 | }; | 187 | }; |
187 | 188 | ||
189 | constructor(props) { | ||
190 | super(props); | ||
191 | |||
192 | this.state = { | ||
193 | lockedPassword: '', | ||
194 | }; | ||
195 | } | ||
196 | |||
188 | onSubmit(settingsData) { | 197 | onSubmit(settingsData) { |
189 | const { todos, workspaces } = this.props.stores; | 198 | const { todos, workspaces } = this.props.stores; |
190 | const { | 199 | const { |
@@ -195,6 +204,10 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
195 | workspaces: workspaceActions, | 204 | workspaces: workspaceActions, |
196 | } = this.props.actions; | 205 | } = this.props.actions; |
197 | 206 | ||
207 | this.setState({ | ||
208 | lockedPassword: settingsData.lockedPassword, | ||
209 | }); | ||
210 | |||
198 | app.launchOnStartup({ | 211 | app.launchOnStartup({ |
199 | enable: settingsData.autoLaunchOnStart, | 212 | enable: settingsData.autoLaunchOnStart, |
200 | openInBackground: settingsData.autoLaunchInBackground, | 213 | openInBackground: settingsData.autoLaunchInBackground, |
@@ -217,7 +230,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
217 | predefinedTodoServer: settingsData.predefinedTodoServer, | 230 | predefinedTodoServer: settingsData.predefinedTodoServer, |
218 | customTodoServer: settingsData.customTodoServer, | 231 | customTodoServer: settingsData.customTodoServer, |
219 | lockingFeatureEnabled: settingsData.lockingFeatureEnabled, | 232 | lockingFeatureEnabled: settingsData.lockingFeatureEnabled, |
220 | lockedPassword: settingsData.lockedPassword, | 233 | lockedPassword: hash(String(settingsData.lockedPassword)), |
221 | useTouchIdToUnlock: settingsData.useTouchIdToUnlock, | 234 | useTouchIdToUnlock: settingsData.useTouchIdToUnlock, |
222 | inactivityLock: settingsData.inactivityLock, | 235 | inactivityLock: settingsData.inactivityLock, |
223 | scheduledDNDEnabled: settingsData.scheduledDNDEnabled, | 236 | scheduledDNDEnabled: settingsData.scheduledDNDEnabled, |
@@ -273,6 +286,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
273 | app, settings, user, todos, workspaces, | 286 | app, settings, user, todos, workspaces, |
274 | } = this.props.stores; | 287 | } = this.props.stores; |
275 | const { intl } = this.context; | 288 | const { intl } = this.context; |
289 | const { lockedPassword } = this.state; | ||
276 | 290 | ||
277 | const locales = getSelectOptions({ | 291 | const locales = getSelectOptions({ |
278 | locales: APP_LOCALES, | 292 | locales: APP_LOCALES, |
@@ -395,7 +409,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e | |||
395 | }, | 409 | }, |
396 | lockedPassword: { | 410 | lockedPassword: { |
397 | label: intl.formatMessage(messages.lockPassword), | 411 | label: intl.formatMessage(messages.lockPassword), |
398 | value: settings.all.app.lockedPassword, | 412 | value: lockedPassword, |
399 | default: '', | 413 | default: '', |
400 | type: 'password', | 414 | type: 'password', |
401 | }, | 415 | }, |