Merge pull request #304 from esteemapp/login-refactoring

Login refactoring
This commit is contained in:
uğur erdal 2018-12-27 11:14:41 +03:00 committed by GitHub
commit e39682eba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 566 additions and 505 deletions

View File

@ -5,3 +5,4 @@ OLD_IMAGE_API=
SEARCH_API_TOKEN=
SEARCH_API_URL=
SERVER_LIST_API=
PIN_KEY=

View File

@ -9,7 +9,6 @@ export default EStyleSheet.create({
backgroundColor: '$primaryBlue',
},
input: {
alignItems: 'center',
justifyContent: 'center',
height: 18,
margin: 10,

View File

@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import { Animated } from 'react-native';
import { Animated, Easing, View } from 'react-native';
// Styles
import styles from './pinAnimatedInputStyles';
@ -13,38 +13,73 @@ class PinAnimatedInput extends PureComponent {
constructor(props) {
super(props);
this.state = {};
this.dots = [];
this.dots[0] = new Animated.Value(0);
this.dots[1] = new Animated.Value(0);
this.dots[2] = new Animated.Value(0);
this.dots[3] = new Animated.Value(0);
}
componentWillReceiveProps(nextProps) {
const { loading } = this.props;
if (loading !== nextProps.loading) {
if (nextProps.loading) {
this._startLoadingAnimation();
} else {
this._stopLoadingAnimation();
}
}
}
_startLoadingAnimation = () => {
const { loading } = this.props;
[...Array(4)].map((item, index) => {
this.dots[index].setValue(0);
});
Animated.sequence([
...this.dots.map(item => Animated.timing(item, {
toValue: 1,
duration: 250,
easing: Easing.linear,
})),
]).start(() => {
if (loading) this._startLoadingAnimation();
});
};
_stopLoadingAnimation = () => {
[...Array(4)].map((item, index) => {
this.dots[index].stopAnimation();
});
};
render() {
const { pin } = this.props;
const test = new Animated.Value(0);
const tilt = test.interpolate({
inputRange: [0, 0.3, 0.6, 0.9],
outputRange: [0, -50, 50, 0],
const marginBottom = [];
[...Array(4)].map((item, index) => {
marginBottom[index] = this.dots[index].interpolate({
inputRange: [0, 0.5, 1],
outputRange: [0, 20, 0],
});
});
return (
<Animated.View
style={[
{
transform: [{ translateX: tilt }],
},
styles.container,
]}
>
{[...Array(4)].map((val, index) => {
<View style={[styles.container]}>
{this.dots.map((val, index) => {
if (pin.length > index) {
return (
<Animated.View key={`passwordItem-${index}`} style={styles.input}>
<Animated.View
key={`passwordItem-${index}`}
style={[styles.input, styles.inputWithBackground]}
/>
</Animated.View>
<Animated.View
key={`passwordItem-${index}`}
style={[styles.input, styles.inputWithBackground, { bottom: marginBottom[index] }]}
/>
);
}
return <Animated.View key={`passwordItem-${index}`} style={styles.input} />;
return <View key={`passwordItem-${index}`} style={styles.input} />;
})}
</Animated.View>
</View>
);
}
}

View File

@ -55,10 +55,12 @@ class PostDropdownContainer extends PureComponent {
};
_reblog = () => {
const { currentAccount, content, isLoggedIn } = this.props;
const {
currentAccount, content, isLoggedIn, pinCode,
} = this.props;
if (isLoggedIn) {
reblog(currentAccount, content.author, content.permlink)
.then((result) => {
reblog(currentAccount, pinCode, content.author, content.permlink)
.then(() => {
Alert.alert('Success', 'Rebloged!');
})
.catch((error) => {
@ -98,5 +100,6 @@ class PostDropdownContainer extends PureComponent {
const mapStateToProps = state => ({
isLoggedIn: state.application.isLoggedIn,
currentAccount: state.account.currentAccount,
pinCode: state.account.pin,
});
export default withNavigation(connect(mapStateToProps)(PostDropdownContainer));

View File

@ -43,6 +43,7 @@ class UpvoteContainer extends PureComponent {
isLoggedIn,
isShowPayoutValue,
upvotePercent,
pinCode,
} = this.props;
let author;
let isVoted;
@ -50,10 +51,10 @@ class UpvoteContainer extends PureComponent {
let permlink;
if (content) {
author = content.author;
({ author } = content);
isVoted = content.is_voted;
pendingPayoutValue = content.pending_payout_value;
permlink = content.permlink;
({ permlink } = content);
}
return (
@ -68,6 +69,7 @@ class UpvoteContainer extends PureComponent {
pendingPayoutValue={pendingPayoutValue}
permlink={permlink}
upvotePercent={upvotePercent}
pinCode={pinCode}
/>
);
}
@ -76,7 +78,7 @@ class UpvoteContainer extends PureComponent {
const mapStateToProps = state => ({
isLoggedIn: state.application.isLoggedIn,
upvotePercent: state.application.upvotePercent,
pinCode: state.account.pin,
currentAccount: state.account.currentAccount,
});

View File

@ -75,7 +75,7 @@ class UpvoteView extends Component {
_upvoteContent = async () => {
const {
author, currentAccount, fetchPost, handleSetUpvotePercent, permlink,
author, currentAccount, fetchPost, handleSetUpvotePercent, permlink, pinCode,
} = this.props;
const { sliderValue } = this.state;
@ -92,6 +92,7 @@ class UpvoteView extends Component {
vote(
currentAccount,
pinCode,
author,
permlink,
weight,

View File

@ -5,17 +5,13 @@ import {
setAuthStatus,
getUserDataWithUsername,
updateUserData,
setPinCode,
getPinCode,
updateCurrentUsername,
getUserData,
} from '../../realm/realm';
import { encryptKey, decryptKey } from '../../utils/crypto';
import steemConnect from './steemConnectAPI';
export const Login = (username, password) => {
let publicKeys;
let privateKeys;
export const login = async (username, password) => {
const resultKeys = {
active: null,
memo: null,
@ -24,75 +20,63 @@ export const Login = (username, password) => {
};
let loginFlag = false;
let avatar = '';
// Get user account data from STEEM Blockchain
const account = await getUser(username);
if (!account) {
return Promise.reject(new Error('Invalid pin code, please check and try again'));
}
if (isLoggedInUser(username)) {
return Promise.reject(new Error('You are already logged in, please try to add another account'));
}
return new Promise((resolve, reject) => {
// Get user account data from STEEM Blockchain
getUser(username)
.then((account) => {
if (isLoggedInUser(username)) {
reject(new Error('You are already logged in, please try to add another account'));
}
// Public keys of user
const publicKeys = {
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]),
};
// Public keys of user
publicKeys = {
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(username, password);
// Set private keys of user
privateKeys = getPrivateKeys(username, password);
// Check all keys
Object.keys(publicKeys).map((pubKey) => {
if (publicKeys[pubKey] === privateKeys[pubKey].createPublic().toString()) {
loginFlag = true;
resultKeys[pubKey] = publicKeys[pubKey];
}
});
let jsonMetadata;
try {
jsonMetadata = JSON.parse(account.json_metadata) || '';
} catch (err) {
jsonMetadata = '';
// TODO: handle wrong json format properly
// reject(new Error(err));
}
if (Object.keys(jsonMetadata).length !== 0) {
avatar = jsonMetadata.profile.profile_image || '';
}
if (loginFlag) {
const userData = {
username,
avatar,
authType: 'masterKey',
masterKey: '',
postingKey: '',
activeKey: '',
memoKey: '',
accessToken: '',
};
account.local = userData;
// Save user data to Realm DB
setUserData(userData)
.then(() => {
resolve({ ...account, password });
updateCurrentUsername(account.name);
})
.catch(() => {
reject(new Error('Invalid credentials, please check and try again'));
});
} else {
reject(new Error('Invalid credentials, please check and try again'));
}
})
.catch(() => {
reject(new Error('Invalid credentials, please check and try again'));
});
// Check all keys
Object.keys(publicKeys).map((pubKey) => {
if (publicKeys[pubKey] === privateKeys[pubKey].createPublic().toString()) {
loginFlag = true;
resultKeys[pubKey] = publicKeys[pubKey];
}
});
let jsonMetadata;
try {
jsonMetadata = JSON.parse(account.json_metadata) || '';
} catch (err) {
jsonMetadata = '';
}
if (Object.keys(jsonMetadata).length !== 0) {
avatar = jsonMetadata.profile.profile_image || '';
}
if (loginFlag) {
const userData = {
username,
avatar,
authType: 'masterKey',
masterKey: '',
postingKey: '',
activeKey: '',
memoKey: '',
accessToken: '',
};
account.local = userData;
// Save user data to Realm DB
await setUserData(userData);
await updateCurrentUsername(account.name);
return ({ ...account, password });
}
return Promise.reject(new Error('Invalid pin code, please check and try again'));
};
export const loginWithSC2 = async (accessToken) => {
@ -104,7 +88,7 @@ export const loginWithSC2 = async (accessToken) => {
try {
const jsonMetadata = JSON.parse(account.account.json_metadata);
if (Object.keys(jsonMetadata).length !== 0) {
avatar = jsonMetadata.profile.profile_image;
avatar = jsonMetadata.profile.profile_image || '';
}
} catch (error) {
reject(new Error('Invalid credentials, please check and try again'));
@ -120,26 +104,15 @@ export const loginWithSC2 = async (accessToken) => {
accessToken: '',
};
const authData = {
isLoggedIn: true,
currentUsername: account.account.name,
};
if (isLoggedInUser(account.account.name)) {
reject(new Error('You are already logged in, please try to add another account'));
}
setAuthStatus(authData)
setUserData(userData)
.then(() => {
setUserData(userData)
.then(() => {
account.account.username = account.account.name;
resolve({ ...account.account, accessToken });
updateCurrentUsername(account.account.name);
})
.catch((error) => {
reject(error);
});
account.account.username = account.account.name;
updateCurrentUsername(account.account.name);
resolve({ ...account.account, accessToken });
})
.catch((error) => {
reject(error);
@ -147,90 +120,53 @@ export const loginWithSC2 = async (accessToken) => {
});
};
export const setUserDataWithPinCode = data => new Promise((resolve, reject) => {
let updatedUserData;
export const setUserDataWithPinCode = async (data) => {
const result = getUserDataWithUsername(data.username);
const userData = result[0];
const privateKeys = getPrivateKeys(userData.username, data.password);
if (userData.authType === 'masterKey') {
updatedUserData = {
username: userData.username,
authType: 'masterKey',
masterKey: encryptKey(data.password, data.pinCode),
postingKey: encryptKey(privateKeys.posting.toString(), data.pinCode),
activeKey: encryptKey(privateKeys.active.toString(), data.pinCode),
memoKey: encryptKey(privateKeys.memo.toString(), data.pinCode),
};
} else if (userData.authType === 'steemConnect') {
updatedUserData = {
username: userData.username,
authType: 'steemConnect',
accessToken: encryptKey(data.accessToken, data.pinCode),
masterKey: '',
postingKey: encryptKey(privateKeys.posting.toString(), data.pinCode),
activeKey: encryptKey(privateKeys.active.toString(), data.pinCode),
memoKey: encryptKey(privateKeys.memo.toString(), data.pinCode),
};
}
const updatedUserData = {
username: userData.username,
authType: userData.authType,
accessToken: userData.authType === 'steemConnect' ? encryptKey(data.accessToken, data.pinCode) : '',
masterKey: userData.authType === 'masterKey' ? encryptKey(data.password, data.pinCode) : '',
postingKey: encryptKey(privateKeys.posting.toString(), data.pinCode),
activeKey: encryptKey(privateKeys.active.toString(), data.pinCode),
memoKey: encryptKey(privateKeys.memo.toString(), data.pinCode),
};
updateUserData(updatedUserData)
.then((response) => {
const authData = {
isLoggedIn: true,
currentUsername: userData.username,
};
const response = await updateUserData(updatedUserData);
const authData = {
isLoggedIn: true,
currentUsername: userData.username,
};
setAuthStatus(authData)
.then(() => {
const encriptedPinCode = encryptKey(data.pinCode, 'pin-code');
setPinCode(encriptedPinCode)
.then(() => {
resolve(response);
})
.catch((error) => {
reject(error);
});
})
.catch((error) => {
reject(error);
});
})
.catch((err) => {
reject(err);
});
});
await setAuthStatus(authData);
return (response);
};
export const updatePinCode = async (data) => {
let updatedUserData;
let password = null;
let accessToken = null;
const users = await getUserData();
if (users.length > 0) {
users.forEach(async (userData) => {
const password = decryptKey(userData.masterKey, data.oldPinCode);
const privateKeys = getPrivateKeys(userData.username, password);
if (userData.authType === 'masterKey') {
updatedUserData = {
username: userData.username,
authType: 'masterKey',
masterKey: encryptKey(password, data.pinCode),
postingKey: encryptKey(privateKeys.posting.toString(), data.pinCode),
activeKey: encryptKey(privateKeys.active.toString(), data.pinCode),
memoKey: encryptKey(privateKeys.memo.toString(), data.pinCode),
};
password = decryptKey(userData.masterKey, data.oldPinCode);
} else if (userData.authType === 'steemConnect') {
updatedUserData = {
username: userData.username,
authType: 'steemConnect',
accessToken: encryptKey(data.accessToken, data.pinCode),
masterKey: '',
postingKey: encryptKey(privateKeys.posting.toString(), data.pinCode),
activeKey: encryptKey(privateKeys.active.toString(), data.pinCode),
memoKey: encryptKey(privateKeys.memo.toString(), data.pinCode),
};
accessToken = decryptKey(userData.accessToken, data.oldPinCode);
}
const privateKeys = getPrivateKeys(userData.username, password);
const updatedUserData = {
username: userData.username,
authType: userData.authType,
accessToken: userData.authType === 'steemConnect' ? encryptKey(accessToken, data.pinCode) : '',
masterKey: userData.authType === 'masterKey' ? encryptKey(password, data.pinCode) : '',
postingKey: encryptKey(privateKeys.posting.toString(), data.pinCode),
activeKey: encryptKey(privateKeys.active.toString(), data.pinCode),
memoKey: encryptKey(privateKeys.memo.toString(), data.pinCode),
};
const response = await updateUserData(updatedUserData);
const authData = {
isLoggedIn: true,
@ -238,9 +174,6 @@ export const updatePinCode = async (data) => {
};
await setAuthStatus(authData);
const encriptedPinCode = encryptKey(data.pinCode, 'pin-code');
await setPinCode(encriptedPinCode);
return response;
});
}
@ -252,72 +185,55 @@ export const verifyPinCode = async (data) => {
let account = null;
let loginFlag = false;
if (result.length > 0) {
if (userData.masterKey || userData.accessToken) {
if (userData.authType === 'steemConnect') {
const accessToken = decryptKey(userData.accessToken, data.pinCode);
await steemConnect.setAccessToken(accessToken);
account = await steemConnect.me();
if (account) {
if (userData.authType === 'steemConnect') {
let accessToken;
try {
accessToken = decryptKey(userData.accessToken, data.pinCode);
} catch (error) {
return Promise.reject(new Error('Invalid pin code, please check and try again'));
}
await steemConnect.setAccessToken(accessToken);
account = await steemConnect.me();
if (account) {
loginFlag = true;
}
} else if (userData.authType === 'masterKey') {
const password = decryptKey(userData.masterKey, data.pinCode);
account = await getUser(data.username);
// Public keys of user
const publicKeys = {
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);
// Check all keys
Object.keys(publicKeys).map((pubKey) => {
if (publicKeys[pubKey] === privateKeys[pubKey].createPublic().toString()) {
loginFlag = true;
}
} else if (userData.authType === 'masterKey') {
const password = decryptKey(userData.masterKey, data.pinCode);
account = await getUser(data.username);
// Public keys of user
const publicKeys = {
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);
// Check all keys
Object.keys(publicKeys).map((pubKey) => {
if (publicKeys[pubKey] === privateKeys[pubKey].createPublic().toString()) {
loginFlag = true;
}
});
}
} else {
const encriptedPinCode = await getPinCode();
const pinCode = decryptKey(encriptedPinCode, 'pin-code');
if (pinCode === data.pinCode) {
const res = await setUserDataWithPinCode(data);
if (res) {
loginFlag = true;
}
}
});
}
}
return new Promise((resolve, reject) => {
if (loginFlag) {
const authData = {
isLoggedIn: true,
currentUsername: data.username,
};
const response = {
accessToken: decryptKey(userData.accessToken, data.pinCode),
postingKey: decryptKey(userData.postingKey, data.pinCode),
masterKey: decryptKey(userData.masterKey, data.pinCode),
activeKey: decryptKey(userData.activeKey, data.pinCode),
memoKey: decryptKey(userData.memoKey, data.pinCode),
};
setAuthStatus(authData)
.then(() => {
resolve(response);
})
.catch(() => {
// TODO: create function for throw error
reject(new Error('Unknown error, please contact to eSteem.'));
});
} else {
reject(new Error('Invalid pin code, please check and try again'));
}
});
if (loginFlag) {
const authData = {
isLoggedIn: true,
currentUsername: data.username,
};
const response = {
accessToken: decryptKey(userData.accessToken, data.pinCode),
postingKey: decryptKey(userData.postingKey, data.pinCode),
masterKey: decryptKey(userData.masterKey, data.pinCode),
activeKey: decryptKey(userData.activeKey, data.pinCode),
memoKey: decryptKey(userData.memoKey, data.pinCode),
};
await setAuthStatus(authData);
return (response);
}
return Promise.reject(new Error('Invalid pin code, please check and try again'));
};
export const switchAccount = username => new Promise((resolve, reject) => {

View File

@ -1,5 +1,7 @@
import { Client, PrivateKey } from 'dsteem';
import steemConnect from 'steemconnect';
import Config from 'react-native-config';
import { getServer, getPinCode } from '../../realm/realm';
import { getUnreadActivityCount } from '../esteem/esteem';
@ -31,7 +33,7 @@ const _getClient = async () => {
_getClient();
export const getDigitPinCode = async () => decryptKey(await getPinCode(), 'pin-code');
export const getDigitPinCode = pin => decryptKey(pin, Config.PIN_KEY);
/**
* @method getAccount get account data
@ -194,8 +196,8 @@ export const getIsMuted = async (username, targetUsername) => {
return false;
};
export const ignoreUser = async (currentAccount, data) => {
const digitPinCode = await getDigitPinCode();
export const ignoreUser = async (currentAccount, pin, data) => {
const digitPinCode = getDigitPinCode(pin);
if (currentAccount.local.authType === AUTH_TYPE.MASTER_KEY) {
const key = decryptKey(currentAccount.local.postingKey, digitPinCode);
@ -358,8 +360,8 @@ export const getPostWithComments = async (user, permlink) => {
* @param vote vote object(author, permlink, voter, weight)
* @param postingKey private posting key
*/
export const vote = async (currentAccount, author, permlink, weight) => {
const digitPinCode = await getDigitPinCode();
export const vote = async (currentAccount, pin, author, permlink, weight) => {
const digitPinCode = getDigitPinCode(pin);
if (currentAccount.local.authType === AUTH_TYPE.MASTER_KEY) {
const key = decryptKey(currentAccount.local.postingKey, digitPinCode);
@ -443,8 +445,8 @@ export const transferToken = (data, activeKey) => {
});
};
export const followUser = async (currentAccount, data) => {
const digitPinCode = await getDigitPinCode();
export const followUser = async (currentAccount, pin, data) => {
const digitPinCode = getDigitPinCode(pin);
if (currentAccount.local.authType === AUTH_TYPE.MASTER_KEY) {
const key = decryptKey(currentAccount.local.postingKey, digitPinCode);
@ -484,8 +486,8 @@ export const followUser = async (currentAccount, data) => {
}
};
export const unfollowUser = async (currentAccount, data) => {
const digitPinCode = await getDigitPinCode();
export const unfollowUser = async (currentAccount, pin, data) => {
const digitPinCode = getDigitPinCode(pin);
if (currentAccount.local.authType === AUTH_TYPE.MASTER_KEY) {
const key = decryptKey(currentAccount.local.postingKey, digitPinCode);
@ -620,6 +622,7 @@ export const lookupAccounts = async (username) => {
*/
export const postContent = async (
account,
pin,
parentAuthor,
parentPermlink,
permlink,
@ -630,7 +633,7 @@ export const postContent = async (
voteWeight = null,
) => {
const { name: author } = account;
const digitPinCode = await getDigitPinCode();
const digitPinCode = getDigitPinCode(pin);
if (account.local.authType === AUTH_TYPE.MASTER_KEY) {
const opArray = [
@ -722,8 +725,8 @@ export const postContent = async (
};
// Re-blog
export const reblog = async (account, author, permlink) => {
const pin = await getDigitPinCode();
export const reblog = async (account, pinCode, author, permlink) => {
const pin = getDigitPinCode(pinCode);
if (account.local.authType === AUTH_TYPE.MASTER_KEY) {
const key = decryptKey(account.local.postingKey, pin);

View File

@ -6,6 +6,7 @@ import {
UPDATE_CURRENT_ACCOUNT,
UPDATE_UNREAD_ACTIVITY_COUNT,
REMOVE_OTHER_ACCOUNT,
SET_PIN_CODE,
} from '../constants/constants';
export const fetchAccountFromSteem = (username, password) => (dispatch) => {
@ -43,3 +44,8 @@ export const removeOtherAccount = data => ({
type: REMOVE_OTHER_ACCOUNT,
payload: data,
});
export const setPinCode = data => ({
type: SET_PIN_CODE,
payload: data,
});

View File

@ -28,6 +28,7 @@ export const FETCHING_ACCOUNT = 'FETCHING_ACCOUNT';
export const REMOVE_OTHER_ACCOUNT = 'REMOVE_OTHER_ACCOUNT';
export const UPDATE_CURRENT_ACCOUNT = 'UPDATE_CURRENT_ACCOUNT';
export const UPDATE_UNREAD_ACTIVITY_COUNT = 'UPDATE_UNREAD_ACTIVITY_COUNT';
export const SET_PIN_CODE = 'SET_PIN_CODE';
// UI
export const IS_COLLAPSE_POST_BUTTON = 'IS_COLLAPSE_POST_BUTTON';

View File

@ -4,9 +4,9 @@ import {
ADD_OTHER_ACCOUNT,
UPDATE_CURRENT_ACCOUNT,
UPDATE_UNREAD_ACTIVITY_COUNT,
LOGOUT,
REMOVE_OTHER_ACCOUNT,
LOGOUT_FAIL,
SET_PIN_CODE,
} from '../constants/constants';
const initialState = {
@ -16,6 +16,7 @@ const initialState = {
hasError: false,
errorMessage: null,
isLogingOut: false,
pin: null,
};
export default function (state = initialState, action) {
@ -77,11 +78,12 @@ export default function (state = initialState, action) {
...state,
isLogingOut: true,
};
// case LOGOUT_SUCCESS:
// return {
// ...state,
// initialState,
// };
case SET_PIN_CODE:
return {
...state,
pin: action.payload,
};
default:
return state;

View File

@ -91,38 +91,39 @@ class ApplicationContainer extends Component {
};
_getUserData = async () => {
const { dispatch } = this.props;
const { dispatch, pinCode } = this.props;
let realmData;
let authStatus;
let currentUsername;
await getAuthStatus().then((res) => {
authStatus = res;
currentUsername = res.currentUsername;
getUserData().then((userData) => {
if (userData.length > 0) {
realmData = userData;
({ currentUsername } = res);
if (res) {
getUserData().then((userData) => {
if (userData.length > 0) {
realmData = userData;
userData.forEach((accountData) => {
dispatch(
addOtherAccount({ username: accountData.username }),
);
});
}
});
userData.forEach((accountData) => {
dispatch(addOtherAccount({ username: accountData.username }));
});
}
});
}
});
if (realmData) {
await getUser(currentUsername)
.then((accountData) => {
.then(async (accountData) => {
dispatch(login(true));
const isExistUser = await getExistUser();
const realmObject = realmData.filter(data => data.username === currentUsername);
accountData.local = realmObject[0];
[accountData.local] = realmObject;
dispatch(updateCurrentAccount(accountData));
// If in dev mode pin code does not show
if (__DEV__ === false) {
// eslint-disable-next-line
if (!isExistUser || !pinCode) {
dispatch(openPinCodeModal());
}
this._connectNotificationServer(accountData.name);
@ -142,12 +143,12 @@ class ApplicationContainer extends Component {
getSettings().then((response) => {
if (response) {
response.isDarkTheme && dispatch(isDarkTheme(response.isDarkTheme));
response.language && dispatch(setLanguage(response.language));
response.currency && dispatch(setCurrency(response.currency));
response.notification && dispatch(isNotificationOpen(response.notification));
response.server && dispatch(setApi(response.server));
response.upvotePercent && dispatch(setUpvotePercent(Number(response.upvotePercent)));
if (response.isDarkTheme) dispatch(isDarkTheme(response.isDarkTheme));
if (response.language) dispatch(setLanguage(response.language));
if (response.currency) dispatch(setCurrency(response.currency));
if (response.notification) dispatch(isNotificationOpen(response.notification));
if (response.server) dispatch(setApi(response.server));
if (response.upvotePercent) dispatch(setUpvotePercent(Number(response.upvotePercent)));
this.setState({ isReady: true });
}
@ -158,7 +159,7 @@ class ApplicationContainer extends Component {
const { dispatch, unreadActivityCount } = this.props;
const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`);
ws.onmessage = (e) => {
ws.onmessage = () => {
// a message was received
dispatch(updateUnreadActivityCount(unreadActivityCount + 1));
};
@ -188,9 +189,7 @@ class ApplicationContainer extends Component {
};
_logout = () => {
const {
otherAccounts, currentAccountUsername, dispatch,
} = this.props;
const { otherAccounts, currentAccountUsername, dispatch } = this.props;
removeUserData(currentAccountUsername)
.then(() => {
@ -210,8 +209,7 @@ class ApplicationContainer extends Component {
dispatch(removeOtherAccount(currentAccountUsername));
dispatch(logoutDone());
})
.catch((err) => {
alert('err');
.catch(() => {
});
};
@ -222,11 +220,11 @@ class ApplicationContainer extends Component {
const realmData = getUserDataWithUsername(targetAccountUsername);
const _currentAccount = accountData;
_currentAccount.username = accountData.name;
_currentAccount.local = realmData[0];
[_currentAccount.local] = realmData;
dispatch(updateCurrentAccount(_currentAccount));
});
}
};
render() {
const { selectedLanguage } = this.props;
@ -256,6 +254,7 @@ const mapStateToProps = state => ({
unreadActivityCount: state.account.currentAccount.unread_activity_count,
currentAccountUsername: state.account.currentAccount.name,
otherAccounts: state.account.otherAccounts,
pinCode: state.account.pin,
});
export default connect(mapStateToProps)(ApplicationContainer);

View File

@ -203,7 +203,7 @@ class EditorContainer extends Component {
};
_submitPost = async (fields) => {
const { navigation, currentAccount } = this.props;
const { navigation, currentAccount, pinCode } = this.props;
if (currentAccount) {
this.setState({ isPostSending: true });
@ -217,6 +217,7 @@ class EditorContainer extends Component {
await postContent(
currentAccount,
pinCode,
'',
parentPermlink,
permlink,
@ -237,7 +238,7 @@ class EditorContainer extends Component {
};
_submitReply = async (fields) => {
const { currentAccount } = this.props;
const { currentAccount, pinCode } = this.props;
if (currentAccount) {
this.setState({ isPostSending: true });
@ -253,6 +254,7 @@ class EditorContainer extends Component {
await postContent(
currentAccount,
pinCode,
parentAuthor,
parentPermlink,
permlink,
@ -343,7 +345,7 @@ class EditorContainer extends Component {
const mapStateToProps = state => ({
isLoggedIn: state.application.isLoggedIn,
pinCode: state.account.pin,
currentAccount: state.account.currentAccount,
});

View File

@ -1,11 +1,21 @@
import React, { PureComponent } from 'react';
import { Alert, Linking } from 'react-native';
import { connect } from 'react-redux';
// Services and Actions
import { login } from '../../../providers/steem/auth';
import { lookupAccounts } from '../../../providers/steem/dsteem';
import {
failedAccount,
addOtherAccount,
updateCurrentAccount,
} from '../../../redux/actions/accountAction';
import { login as loginAction, openPinCodeModal } from '../../../redux/actions/applicationActions';
// Middleware
// Constants
import ROUTES from '../../../constants/routeNames';
// Utilities
@ -21,15 +31,61 @@ import LoginScreen from '../screen/loginScreen';
class LoginContainer extends PureComponent {
constructor(props) {
super(props);
this.state = {};
this.state = {
isLoading: false,
};
}
// Component Life Cycle Functions
// Component Functions
_handleOnPressLogin = (username, password) => {
const { dispatch, setPinCodeState } = this.props;
this.setState({ isLoading: true });
login(username, password)
.then((result) => {
if (result) {
dispatch(updateCurrentAccount({ ...result }));
dispatch(addOtherAccount({ username: result.name }));
dispatch(openPinCodeModal());
setPinCodeState({ navigateTo: ROUTES.DRAWER.MAIN });
dispatch(loginAction(true));
}
})
.catch((err) => {
// TODO: Change with global error handling
Alert.alert('Error', err.message);
dispatch(failedAccount(err.message));
this.setState({ isLoading: false });
});
};
_getAccountsWithUsername = async (username) => {
const validUsers = await lookupAccounts(username);
return validUsers;
};
_handleSignUp = () => {
Linking.openURL('https://signup.steemit.com/?ref=esteem').catch(err => alert('An error occurred', err));
};
render() {
return <LoginScreen {...this.props} />;
const { isLoading } = this.state;
const { navigation, setPinCodeState } = this.props;
return (
<LoginScreen
handleOnPressLogin={this._handleOnPressLogin}
getAccountsWithUsername={this._getAccountsWithUsername}
handleSignUp={this._handleSignUp}
isLoading={isLoading}
navigation={navigation}
setPinCodeState={setPinCodeState}
/>
);
}
}

View File

@ -1,30 +1,20 @@
import React, { PureComponent } from 'react';
import {
View, Linking, StatusBar, Platform, Alert,
} from 'react-native';
import { View, StatusBar, Platform } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import ScrollableTabView from '@esteemapp/react-native-scrollable-tab-view';
import { injectIntl } from 'react-intl';
// Actions
import {
failedAccount,
addOtherAccount,
updateCurrentAccount,
} from '../../../redux/actions/accountAction';
import { login as loginAction, openPinCodeModal } from '../../../redux/actions/applicationActions';
import SteemConnect from '../../steem-connect/steemConnect';
// Internal Components
import { FormInput } from '../../../components/formInput';
import { InformationArea } from '../../../components/informationArea';
import { Login } from '../../../providers/steem/auth';
import { LoginHeader } from '../../../components/loginHeader';
import { lookupAccounts } from '../../../providers/steem/dsteem';
import { MainButton } from '../../../components/mainButton';
import { Modal } from '../../../components';
import { TabBar } from '../../../components/tabBar';
import { TextButton } from '../../../components/buttons';
import SteemConnect from '../../steem-connect/steemConnect';
// Constants
import { default as ROUTES } from '../../../constants/routeNames';
@ -40,51 +30,26 @@ class LoginScreen extends PureComponent {
this.state = {
username: '',
password: '',
isLoading: false,
isUsernameValid: true,
keyboardIsOpen: false,
isModalOpen: false,
};
}
_handleOnPressLogin = () => {
const { dispatch, setPinCodeState } = this.props;
const { password, username } = this.state;
this.setState({ isLoading: true });
Login(username, password)
.then((result) => {
if (result) {
dispatch(updateCurrentAccount({ ...result }));
dispatch(addOtherAccount({ username: result.name }));
dispatch(openPinCodeModal());
setPinCodeState({ navigateTo: ROUTES.DRAWER.MAIN });
dispatch(loginAction(true));
}
})
.catch((err) => {
// TODO: Change with global error handling
Alert.alert('Error', err.message);
dispatch(failedAccount(err.message));
this.setState({ isLoading: false });
});
};
_handleUsernameChange = async (username) => {
await this.setState({ username });
const validUsers = await lookupAccounts(username);
const isValid = validUsers.includes(username);
this.setState({ isUsernameValid: isValid });
};
_handleOnPasswordChange = (value) => {
this.setState({ password: value });
};
_handleSignUp = () => {
Linking.openURL('https://signup.steemit.com/?ref=esteem').catch(err => alert('An error occurred', err));
_handleUsernameChange = (username) => {
const { getAccountsWithUsername } = this.props;
this.setState({ username });
getAccountsWithUsername(username).then((res) => {
const isValid = res.includes(username);
this.setState({ isUsernameValid: isValid });
});
};
_handleOnModalToggle = () => {
@ -93,14 +58,16 @@ class LoginScreen extends PureComponent {
};
render() {
const { navigation, intl, setPinCodeState } = this.props;
const {
navigation,
intl,
setPinCodeState,
handleOnPressLogin,
handleSignUp,
isLoading,
username,
isUsernameValid,
keyboardIsOpen,
password,
isModalOpen,
} = this.props;
const {
username, isUsernameValid, keyboardIsOpen, password, isModalOpen,
} = this.state;
return (
@ -114,7 +81,7 @@ class LoginScreen extends PureComponent {
description={intl.formatMessage({
id: 'login.signin_title',
})}
onPress={() => this._handleSignUp()}
onPress={() => handleSignUp()}
rightButtonText={intl.formatMessage({
id: 'login.signup',
})}
@ -125,7 +92,7 @@ class LoginScreen extends PureComponent {
renderTabBar={() => (
<TabBar
style={styles.tabbar}
tabUnderlineDefaultWidth={100} // default containerWidth / (numberOfTabs * 4)
tabUnderlineDefaultWidth={100}
tabUnderlineScaleX={2} // default 3
activeColor="#357ce6"
inactiveColor="#222"
@ -187,7 +154,7 @@ class LoginScreen extends PureComponent {
})}
/>
<MainButton
onPress={this._handleOnPressLogin}
onPress={() => handleOnPressLogin(username, password)}
iconName="md-person"
iconColor="white"
text={intl.formatMessage({

View File

@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { Alert } from 'react-native';
import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
import Config from 'react-native-config';
import {
setUserDataWithPinCode,
@ -12,7 +13,10 @@ import {
// Actions & Services
import { closePinCodeModal } from '../../../redux/actions/applicationActions';
import { getExistUser, setExistUser, getUserDataWithUsername } from '../../../realm/realm';
import { updateCurrentAccount } from '../../../redux/actions/accountAction';
import { updateCurrentAccount, setPinCode as savePinCode } from '../../../redux/actions/accountAction';
// Utils
import { encryptKey, decryptKey } from '../../../utils/crypto';
// Component
import PinCodeScreen from '../screen/pinCodeScreen';
@ -33,9 +37,10 @@ class PinCodeContainer extends Component {
// TODO: these text should move to view!
componentDidMount() {
this._getDataFromStorage().then(() => {
const { intl, isReset } = this.props;
const { intl } = this.props;
const { isExistUser } = this.state;
if (isExistUser || !isReset) {
if (isExistUser) {
this.setState({
informationText: intl.formatMessage({
id: 'pincode.enter_text',
@ -62,144 +67,203 @@ class PinCodeContainer extends Component {
});
});
_setPinCode = pin => new Promise((resolve, reject) => {
_resetPinCode = pin => new Promise((resolve, reject) => {
const {
currentAccount,
dispatch,
accessToken,
setWrappedComponentState,
navigateTo,
navigation,
intl,
isReset,
} = this.props;
const {
isExistUser, pinCode, isOldPinVerified, oldPinCode,
} = this.state;
const { isOldPinVerified, oldPinCode } = this.state;
if (isReset) {
const pinData = {
pinCode: pin,
password: currentAccount ? currentAccount.password : '',
username: currentAccount ? currentAccount.name : '',
accessToken,
oldPinCode,
};
const pinData = {
pinCode: pin,
password: currentAccount ? currentAccount.password : '',
username: currentAccount ? currentAccount.name : '',
accessToken,
oldPinCode,
};
if (isOldPinVerified) {
updatePinCode(pinData).then((response) => {
const _currentAccount = currentAccount;
_currentAccount.local = response;
if (isOldPinVerified) {
updatePinCode(pinData).then((response) => {
const _currentAccount = currentAccount;
_currentAccount.local = response;
dispatch(updateCurrentAccount({ ..._currentAccount }));
dispatch(updateCurrentAccount({ ..._currentAccount }));
this._savePinCode(pin);
dispatch(closePinCodeModal());
if (navigateTo) {
navigation.navigate(navigateTo);
}
resolve();
});
} else {
verifyPinCode(pinData)
.then(() => {
this.setState({ isOldPinVerified: true });
this.setState({
informationText: intl.formatMessage({
id: 'pincode.set_new',
}),
pinCode: null,
oldPinCode: pin,
});
resolve();
})
.catch((err) => {
Alert.alert('Warning', err.message);
reject(err);
});
}
} else if (isExistUser) {
// If the user is exist, we are just checking to pin and navigating to home screen
const pinData = {
pinCode: pin,
password: currentAccount ? currentAccount.password : '',
username: currentAccount ? currentAccount.name : '',
accessToken,
};
dispatch(closePinCodeModal());
if (navigateTo) {
navigation.navigate(navigateTo);
}
resolve();
});
} else {
verifyPinCode(pinData)
.then((res) => {
setWrappedComponentState(res);
dispatch(closePinCodeModal());
const realmData = getUserDataWithUsername(currentAccount.name);
const _currentAccount = currentAccount;
_currentAccount.username = _currentAccount.name;
_currentAccount.local = realmData[0];
dispatch(updateCurrentAccount({ ..._currentAccount }));
if (navigateTo) {
navigation.navigate(navigateTo);
}
.then(() => {
this.setState({ isOldPinVerified: true });
this.setState({
informationText: intl.formatMessage({
id: 'pincode.set_new',
}),
pinCode: null,
oldPinCode: pin,
});
resolve();
})
.catch((err) => {
Alert.alert('Warning', err.message);
reject(err);
});
} else if (!pinCode) {
// If the user is logging in for the first time, the user should set to pin
this.setState({
informationText: intl.formatMessage({
id: 'pincode.write_again',
}),
pinCode: pin,
});
resolve();
} else if (pinCode === pin) {
const pinData = {
pinCode: pin,
password: currentAccount ? currentAccount.password : '',
username: currentAccount ? currentAccount.name : '',
accessToken,
};
setUserDataWithPinCode(pinData).then((response) => {
const _currentAccount = currentAccount;
_currentAccount.local = response;
dispatch(updateCurrentAccount({ ..._currentAccount }));
setExistUser(true).then(() => {
dispatch(closePinCodeModal());
if (navigateTo) {
navigation.navigate(navigateTo);
}
resolve();
});
});
} else {
this.setState({
informationText: intl.formatMessage({
id: 'pincode.write_again',
}),
});
setTimeout(() => {
this.setState({
informationText: 'setup screen',
pinCode: null,
});
resolve();
}, 1000);
}
});
_setFirstPinCode = pin => new Promise((resolve) => {
const {
currentAccount,
dispatch,
accessToken,
navigateTo,
navigation,
} = this.props;
const pinData = {
pinCode: pin,
password: currentAccount ? currentAccount.password : '',
username: currentAccount ? currentAccount.name : '',
accessToken,
};
setUserDataWithPinCode(pinData).then((response) => {
const _currentAccount = currentAccount;
_currentAccount.local = response;
dispatch(updateCurrentAccount({ ..._currentAccount }));
setExistUser(true).then(() => {
this._savePinCode(pin);
dispatch(closePinCodeModal());
if (navigateTo) {
navigation.navigate(navigateTo);
}
resolve();
});
});
});
_verifyPinCode = pin => new Promise((resolve, reject) => {
const {
currentAccount,
dispatch,
accessToken,
navigateTo,
navigation,
setWrappedComponentState,
} = this.props;
// If the user is exist, we are just checking to pin and navigating to home screen
const pinData = {
pinCode: pin,
password: currentAccount ? currentAccount.password : '',
username: currentAccount ? currentAccount.name : '',
accessToken,
};
verifyPinCode(pinData)
.then((res) => {
setWrappedComponentState(res);
this._savePinCode(pin);
const realmData = getUserDataWithUsername(currentAccount.name);
const _currentAccount = currentAccount;
_currentAccount.username = _currentAccount.name;
[_currentAccount.local] = realmData;
dispatch(updateCurrentAccount({ ..._currentAccount }));
dispatch(closePinCodeModal());
if (navigateTo) {
navigation.navigate(navigateTo);
}
})
.catch((err) => {
Alert.alert('Warning', err.message);
reject(err);
});
});
_savePinCode = (pin) => {
const { dispatch } = this.props;
const encryptedPin = encryptKey(pin, Config.PIN_KEY);
dispatch(savePinCode(encryptedPin));
}
_setPinCode = async (pin, isReset) => {
const {
intl, currentAccount, applicationPinCode,
} = this.props;
const {
isExistUser, pinCode,
} = this.state;
const realmData = getUserDataWithUsername(currentAccount.name);
const userData = realmData[0];
// For exist users
if (isReset) { await this._resetPinCode(pin); return true; }
if (isExistUser) {
if (!userData.accessToken && !userData.masterKey && applicationPinCode) {
const verifiedPin = decryptKey(applicationPinCode, Config.PIN_KEY);
if (verifiedPin === pin) {
await this._setFirstPinCode(pin);
} else {
Alert.alert('Warning', 'Invalid pin code, please check and try again');
}
} else {
await this._verifyPinCode(pin);
}
return true;
}
// For new users
if (pinCode === pin) { await this._setFirstPinCode(pin); return true; }
if (!pinCode) {
// If the user is logging in for the first time, the user should set to pin
await this.setState({
informationText: intl.formatMessage({
id: 'pincode.write_again',
}),
pinCode: pin,
});
return Promise.resolve();
}
await this.setState({
informationText: intl.formatMessage({
id: 'pincode.write_again',
}),
});
await setTimeout(() => {
this.setState({
informationText: intl.formatMessage({
id: 'pincode.set_new',
}),
pinCode: null,
});
return Promise.resolve();
}, 1000);
};
render() {
const { currentAccount, intl } = this.props;
const { currentAccount, intl, isReset } = this.props;
const { informationText, isExistUser } = this.state;
return (
<PinCodeScreen
informationText={informationText}
setPinCode={this._setPinCode}
setPinCode={pin => this._setPinCode(pin, isReset)}
showForgotButton={isExistUser}
username={currentAccount.name}
intl={intl}
{...this.props}
/>
);
}
@ -207,6 +271,7 @@ class PinCodeContainer extends Component {
const mapStateToProps = state => ({
currentAccount: state.account.currentAccount,
applicationPinCode: state.account.pin,
});
export default injectIntl(connect(mapStateToProps)(PinCodeContainer));

View File

@ -11,6 +11,7 @@ class PinCodeScreen extends PureComponent {
super(props);
this.state = {
pin: '',
loading: false,
};
}
@ -18,10 +19,12 @@ class PinCodeScreen extends PureComponent {
// Component Functions
_handleKeyboardOnPress = (value) => {
_handleKeyboardOnPress = async (value) => {
const { setPinCode } = this.props;
const { pin } = this.state;
const { pin, loading } = this.state;
if (loading) {
return;
}
if (value === 'clear') {
this.setState({ pin: '' });
return;
@ -31,14 +34,15 @@ class PinCodeScreen extends PureComponent {
if (pin.length < 3) {
this.setState({ pin: newPin });
} else if (pin.length === 3) {
this.setState({ pin: newPin });
await this.setState({ pin: newPin, loading: true });
setPinCode(`${pin}${value}`)
.then(() => {
// TODO: fix unmounted component error
this.setState({ pin: '' });
this.setState({ pin: '', loading: false });
})
.catch(() => {
this.setState({ pin: '' });
this.setState({ pin: '', loading: false });
});
} else if (pin.length > 3) {
this.setState({ pin: `${value}` });
@ -49,7 +53,7 @@ class PinCodeScreen extends PureComponent {
const {
informationText, showForgotButton, username, intl,
} = this.props;
const { pin } = this.state;
const { pin, loading } = this.state;
return (
<View style={styles.container}>
@ -63,7 +67,7 @@ class PinCodeScreen extends PureComponent {
<Text style={styles.informationText}>{informationText}</Text>
</View>
<View style={styles.animatedView}>
<PinAnimatedInput pin={pin} />
<PinAnimatedInput pin={pin} loading={loading} />
</View>
<View style={styles.numericKeyboardView}>
<NumericKeyboard onPress={this._handleKeyboardOnPress} />

View File

@ -62,8 +62,12 @@ class ProfileContainer extends Component {
};
componentWillReceiveProps(nextProps) {
const { navigation, currentAccount, activeBottomTab, isLoggedIn } = this.props;
const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name;
const {
navigation, currentAccount, activeBottomTab, isLoggedIn,
} = this.props;
const currentUsername = currentAccount.name
!== nextProps.currentAccount.name
&& nextProps.currentAccount.name;
const isParamsChange = nextProps.navigation.state
&& navigation.state
&& nextProps.navigation.state.params
@ -88,7 +92,6 @@ class ProfileContainer extends Component {
this._loadProfile(selectedUser && selectedUser.username);
}
}
_getReplies = async (user) => {
@ -99,39 +102,39 @@ class ProfileContainer extends Component {
comments: result,
});
})
.catch((err) => {});
.catch(() => {});
};
_handleFollowUnfollowUser = async (isFollowAction) => {
const { username, isFollowing } = this.state;
const { currentAccount } = this.props;
const { currentAccount, pinCode } = this.props;
this.setState({
isProfileLoading: true,
});
if (isFollowAction && !isFollowing) {
this._followUser(currentAccount, currentAccount.name, username);
this._followUser(currentAccount, pinCode, currentAccount.name, username);
} else {
this._unfollowUser(currentAccount, currentAccount.name, username);
this._unfollowUser(currentAccount, pinCode, currentAccount.name, username);
}
};
_handleMuteUnmuteUser = async (isMuteAction) => {
const { username, isMuted } = this.state;
const { currentAccount } = this.props;
const { username } = this.state;
const { currentAccount, pinCode } = this.props;
this.setState({
isProfileLoading: true,
});
if (isMuteAction) {
this._muteUser(currentAccount, currentAccount.name, username);
this._muteUser(currentAccount, pinCode, currentAccount.name, username);
}
};
_unfollowUser = (currentAccount, follower, following) => {
unfollowUser(currentAccount, {
_unfollowUser = (currentAccount, pinCode, follower, following) => {
unfollowUser(currentAccount, pinCode, {
follower,
following,
})
@ -143,8 +146,8 @@ class ProfileContainer extends Component {
});
};
_followUser = (currentAccount, follower, following) => {
followUser(currentAccount, {
_followUser = (currentAccount, pinCode, follower, following) => {
followUser(currentAccount, pinCode, {
follower,
following,
})
@ -156,8 +159,8 @@ class ProfileContainer extends Component {
});
};
_muteUser = async (currentAccount, follower, following) => {
ignoreUser(currentAccount, {
_muteUser = async (currentAccount, pinCode, follower, following) => {
ignoreUser(currentAccount, pinCode, {
follower,
following,
})
@ -304,6 +307,7 @@ class ProfileContainer extends Component {
const mapStateToProps = state => ({
isLoggedIn: state.application.isLoggedIn,
currentAccount: state.account.currentAccount,
pinCode: state.account.pin,
isDarkTheme: state.application.isDarkTheme,
activeBottomTab: state.ui.activeBottomTab,
});

View File

@ -85,7 +85,7 @@ class SettingsContainer extends Component {
};
_handleToggleChanged = (action, actionType) => {
const { dispatch, setPinCodeState } = this.props;
const { dispatch } = this.props;
switch (actionType) {
case 'notification':
@ -97,11 +97,6 @@ class SettingsContainer extends Component {
dispatch(isDarkTheme(action));
setTheme(action);
break;
case 'pincode':
// test
dispatch(openPinCodeModal());
setPinCodeState({ isReset: true });
break;
default:
break;
}
@ -111,8 +106,8 @@ class SettingsContainer extends Component {
const { dispatch, setPinCodeState } = this.props;
switch (actionType) {
case 'pincode':
dispatch(openPinCodeModal());
setPinCodeState({ isReset: true });
dispatch(openPinCodeModal());
break;
default:
break;

View File

@ -39,7 +39,7 @@ class SteemConnect extends PureComponent {
if (result) {
dispatch(updateCurrentAccount({ ...result }));
dispatch(addOtherAccount({ username: result.name }));
dispatch(loginAction());
dispatch(loginAction(true));
dispatch(openPinCodeModal());
setPinCodeState({ accessToken, navigateTo: ROUTES.DRAWER.MAIN });
} else {