Merge pull request #1145 from esteemapp/bugfix/authority

Fixed authority issue
This commit is contained in:
uğur erdal 2019-09-06 13:46:54 +03:00 committed by GitHub
commit d077149998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
import * as dsteem from 'dsteem'; import * as dsteem from 'dsteem';
import sha256 from 'crypto-js/sha256'; import sha256 from 'crypto-js/sha256';
import Config from 'react-native-config'; import Config from 'react-native-config';
import get from 'lodash/get';
import { getUser } from './dsteem'; import { getUser } from './dsteem';
import { import {
@ -169,6 +170,16 @@ export const setUserDataWithPinCode = async data => {
const result = getUserDataWithUsername(data.username); const result = getUserDataWithUsername(data.username);
const userData = result[0]; const userData = result[0];
if (!data.password) {
const publicKey =
get(userData, 'masterKey') ||
get(userData, 'activeKey') ||
get(userData, 'memoKey') ||
get(userData, 'postingKey');
data.password = decryptKey(publicKey, data.pinCode);
}
const updatedUserData = getUpdatedUserData(userData, data); const updatedUserData = getUpdatedUserData(userData, data);
await setPinCode(data.pinCode); await setPinCode(data.pinCode);
@ -188,8 +199,19 @@ export const updatePinCode = data =>
getUserData().then(async users => { getUserData().then(async users => {
if (users && users.length > 0) { if (users && users.length > 0) {
await users.forEach(userData => { await users.forEach(userData => {
if (userData.authType === AUTH_TYPE.MASTER_KEY) { if (
data.password = decryptKey(userData.masterKey, data.oldPinCode); userData.authType === AUTH_TYPE.MASTER_KEY ||
userData.authType === AUTH_TYPE.ACTIVE_KEY ||
userData.authType === AUTH_TYPE.MEMO_KEY ||
userData.authType === AUTH_TYPE.POSTING_KEY
) {
const publicKey =
get(userData, 'masterKey') ||
get(userData, 'activeKey') ||
get(userData, 'memoKey') ||
get(userData, 'postingKey');
data.password = decryptKey(publicKey, data.oldPinCode);
} else if (userData.authType === AUTH_TYPE.STEEM_CONNECT) { } else if (userData.authType === AUTH_TYPE.STEEM_CONNECT) {
data.accessToken = decryptKey(userData.accessToken, data.oldPinCode); data.accessToken = decryptKey(userData.accessToken, data.oldPinCode);
} }