Fixed pin code bug after first login

This commit is contained in:
mistikk 2018-11-08 11:44:26 +01:00
parent 9e823e3656
commit a7710b013b
3 changed files with 16 additions and 21 deletions

View File

@ -1,5 +1,5 @@
import * as dsteem from 'dsteem';
import { getAccount } from './dsteem';
import { getUser } from './dsteem';
import {
setUserData,
setAuthStatus,
@ -26,16 +26,12 @@ export const Login = (username, password) => {
return new Promise((resolve, reject) => {
// Get user account data from STEEM Blockchain
getAccount(username)
.then((result) => {
getUser(username)
.then((account) => {
if (isLoggedInUser(username)) {
reject(new Error('You are already logged in, please try to add another account'));
} else if (result.length < 1) {
reject(new Error('Invalid credentails, please check and try again'));
}
const account = result[0];
// Public keys of user
publicKeys = {
active: account.active.key_auths.map(x => x[0]),
@ -208,14 +204,14 @@ export const verifyPinCode = async (data) => {
}
} else if (userData.authType === 'masterKey') {
const password = decryptKey(userData.masterKey, data.pinCode);
account = await getAccount(data.username);
account = await getUser(data.username);
// Public keys of user
const publicKeys = {
active: account[0].active.key_auths.map(x => x[0]),
memo: account[0].memo_key,
owner: account[0].owner.key_auths.map(x => x[0]),
posting: account[0].posting.key_auths.map(x => x[0]),
active: account.active.key_auths.map(x => x[0]),
memo: account.memo_key,
owner: account.owner.key_auths.map(x => x[0]),
posting: account.posting.key_auths.map(x => x[0]),
};
// Set private keys of user
const privateKeys = getPrivateKeys(data.username, password);
@ -267,9 +263,8 @@ export const verifyPinCode = async (data) => {
};
export const switchAccount = username => new Promise((resolve, reject) => {
getAccount(username)
.then((result) => {
const account = result[0];
getUser(username)
.then((account) => {
updateCurrentUsername(username).then(() => {
resolve(account);
}).catch(() => {

View File

@ -1,4 +1,4 @@
import { getAccount } from '../../providers/steem/dsteem';
import { getUser } from '../../providers/steem/dsteem';
import {
FETCH_ACCOUNT_FAIL,
FETCHING_ACCOUNT,
@ -9,10 +9,10 @@ import {
export const fetchAccountFromSteem = (username, password) => (dispatch) => {
dispatch({ type: FETCHING_ACCOUNT });
return getAccount(username)
return getUser(username)
.then(res => dispatch({
type: UPDATE_CURRENT_ACCOUNT,
payload: { ...res[0], password },
payload: { ...res, password },
}))
.catch(err => dispatch({ type: FETCH_ACCOUNT_FAIL, payload: err }));
};

View File

@ -1,4 +1,4 @@
import { getAccount } from '../../providers/steem/dsteem';
import { getUser } from '../../providers/steem/dsteem';
import {
FETCH_USER,
FETCH_USER_SUCCESS,
@ -18,8 +18,8 @@ export function fetchAccount(user) {
return (dispatch) => {
dispatch({ type: FETCH_USER });
return getAccount(user)
.then(res => dispatch({ type: FETCH_USER_SUCCESS, payload: res[0] }))
return getUser(user)
.then(res => dispatch({ type: FETCH_USER_SUCCESS, payload: res }))
.catch(err => dispatch({ type: FETCH_USER_FAIL, payload: err }));
};
}