Changed pin read method

This commit is contained in:
Mustafa Buyukcelebi 2018-12-25 17:19:14 +03:00
parent 659cf61444
commit 5636db836e
7 changed files with 52 additions and 37 deletions

View File

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

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

@ -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);
@ -355,8 +357,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);
@ -440,8 +442,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);
@ -481,8 +483,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);
@ -617,6 +619,7 @@ export const lookupAccounts = async (username) => {
*/
export const postContent = async (
account,
pin,
parentAuthor,
parentPermlink,
permlink,
@ -627,7 +630,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 = [
@ -719,8 +722,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

@ -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

@ -65,7 +65,9 @@ class ProfileContainer extends Component {
componentWillReceiveProps(nextProps) {
const { navigation, currentAccount } = this.props;
const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name;
const currentUsername = currentAccount.name
!== nextProps.currentAccount.name
&& nextProps.currentAccount.name;
const isParamsChange = nextProps.navigation.state
&& navigation.state
&& nextProps.navigation.state.params
@ -90,39 +92,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,
})
@ -134,8 +136,8 @@ class ProfileContainer extends Component {
});
};
_followUser = (currentAccount, follower, following) => {
followUser(currentAccount, {
_followUser = (currentAccount, pinCode, follower, following) => {
followUser(currentAccount, pinCode, {
follower,
following,
})
@ -147,8 +149,8 @@ class ProfileContainer extends Component {
});
};
_muteUser = async (currentAccount, follower, following) => {
ignoreUser(currentAccount, {
_muteUser = async (currentAccount, pinCode, follower, following) => {
ignoreUser(currentAccount, pinCode, {
follower,
following,
})
@ -295,6 +297,7 @@ class ProfileContainer extends Component {
const mapStateToProps = state => ({
isLoggedIn: state.application.isLoggedIn,
currentAccount: state.account.currentAccount,
pinCode: state.account.pin,
isDarkTheme: state.application.isDarkTheme,
});