From f5004f2d7a9f15fcf901ea83d817dd2f2e4d09b0 Mon Sep 17 00:00:00 2001 From: Sofiya Tepikin Date: Mon, 19 Sep 2022 15:15:48 +0200 Subject: [PATCH] Use jshashes on Enter new password --- .../settings/password/enter-new-password.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/components/settings/password/enter-new-password.js b/components/settings/password/enter-new-password.js index 4855350..cfd80e4 100644 --- a/components/settings/password/enter-new-password.js +++ b/components/settings/password/enter-new-password.js @@ -1,35 +1,24 @@ -import React, { useState, useEffect } from 'react' +import React, { useState } from 'react' import { KeyboardAvoidingView, StyleSheet } from 'react-native' -import nodejs from 'nodejs-mobile-react-native' import PropTypes from 'prop-types' +import { SHA512 } from 'jshashes' import AppText from '../../common/app-text' import AppTextInput from '../../common/app-text-input' import Button from '../../common/button' -import { requestHash } from '../../../db' import { Colors, Spacing } from '../../../styles' import settings from '../../../i18n/en/settings' -const LISTENER_TYPE = 'create-or-change-pw' - const EnterNewPassword = ({ changeEncryptionAndRestart }) => { const [password, setPassword] = useState('') const [passwordConfirmation, setPasswordConfirmation] = useState('') const [shouldShowErrorMessage, setShouldShowErrorMessage] = useState(false) - useEffect(() => { - const listener = nodejs.channel.addListener( - LISTENER_TYPE, - changeEncryptionAndRestart, - this - ) - return () => listener.remove() - }, []) - const savePassword = () => { if (comparePasswords()) { - requestHash(LISTENER_TYPE, password) + const hash = new SHA512().hex(password) + changeEncryptionAndRestart(hash) } else { setShouldShowErrorMessage(true) }