mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-24 17:09:13 +03:00
Removed console logs. Fixed reset pin bugs
This commit is contained in:
parent
bd64a5c60c
commit
34199517b2
@ -147,34 +147,33 @@ export const setUserDataWithPinCode = async (data) => {
|
||||
};
|
||||
|
||||
export const updatePinCode = async (data) => {
|
||||
let password = null;
|
||||
let accessToken = null;
|
||||
const users = await getUserData();
|
||||
console.log('users :', users);
|
||||
if (users.length > 0) {
|
||||
users.forEach(async (userData) => {
|
||||
console.log('userData :', userData);
|
||||
console.log('data.oldPinCode :', data.oldPinCode);
|
||||
const password = decryptKey(userData.masterKey, data.oldPinCode);
|
||||
if (userData.authType === 'masterKey') {
|
||||
password = decryptKey(userData.masterKey, data.oldPinCode);
|
||||
} else if (userData.authType === 'steemConnect') {
|
||||
accessToken = decryptKey(userData.accessToken, data.oldPinCode);
|
||||
}
|
||||
const privateKeys = getPrivateKeys(userData.username, password);
|
||||
console.log('password :', password);
|
||||
const updatedUserData = {
|
||||
username: userData.username,
|
||||
authType: userData.authType,
|
||||
accessToken: userData.authType === 'steemConnect' ? encryptKey(data.accessToken, data.pinCode) : '',
|
||||
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),
|
||||
};
|
||||
console.log('updateUserData :', updateUserData);
|
||||
const response = await updateUserData(updatedUserData);
|
||||
console.log('response :', response);
|
||||
const authData = {
|
||||
isLoggedIn: true,
|
||||
currentUsername: userData.username,
|
||||
};
|
||||
|
||||
await setAuthStatus(authData);
|
||||
console.log('authData :', authData);
|
||||
return response;
|
||||
});
|
||||
}
|
||||
@ -182,12 +181,9 @@ export const updatePinCode = async (data) => {
|
||||
|
||||
export const verifyPinCode = async (data) => {
|
||||
const result = getUserDataWithUsername(data.username);
|
||||
console.log('data :', data);
|
||||
console.log('result :', result);
|
||||
const userData = result[0];
|
||||
let account = null;
|
||||
let loginFlag = false;
|
||||
console.log('userData :', userData);
|
||||
if (result.length > 0) {
|
||||
if (userData.authType === 'steemConnect') {
|
||||
const accessToken = decryptKey(userData.accessToken, data.pinCode);
|
||||
@ -198,9 +194,7 @@ export const verifyPinCode = async (data) => {
|
||||
}
|
||||
} else if (userData.authType === 'masterKey') {
|
||||
const password = decryptKey(userData.masterKey, data.pinCode);
|
||||
console.log('password :', password);
|
||||
account = await getUser(data.username);
|
||||
console.log('account :', account);
|
||||
// Public keys of user
|
||||
const publicKeys = {
|
||||
active: account.active.key_auths.map(x => x[0]),
|
||||
@ -213,15 +207,12 @@ console.log('account :', account);
|
||||
|
||||
// Check all keys
|
||||
Object.keys(publicKeys).map((pubKey) => {
|
||||
console.log('publicKeys[pubKey] :', publicKeys[pubKey]);
|
||||
console.log('privateKeys[pubKey].createPublic().toString() :', privateKeys[pubKey].createPublic().toString());
|
||||
if (publicKeys[pubKey] === privateKeys[pubKey].createPublic().toString()) {
|
||||
loginFlag = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log('loginFlag :', loginFlag);
|
||||
if (loginFlag) {
|
||||
const authData = {
|
||||
isLoggedIn: true,
|
||||
@ -234,7 +225,6 @@ console.log('account :', account);
|
||||
activeKey: decryptKey(userData.activeKey, data.pinCode),
|
||||
memoKey: decryptKey(userData.memoKey, data.pinCode),
|
||||
};
|
||||
console.log('response :', response);
|
||||
await setAuthStatus(authData);
|
||||
return (response);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ class PinCodeContainer extends Component {
|
||||
isOldPinVerified: false,
|
||||
oldPinCode: null,
|
||||
};
|
||||
this._setPinCode = this._setPinCode.bind(this);
|
||||
}
|
||||
|
||||
// TODO: if check for decide to set to pin or verify to pin page
|
||||
@ -51,10 +52,6 @@ class PinCodeContainer extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps){
|
||||
console.log('nextProps :', nextProps);
|
||||
}
|
||||
|
||||
_getDataFromStorage = () => new Promise((resolve) => {
|
||||
getExistUser().then((isExistUser) => {
|
||||
this.setState(
|
||||
@ -67,7 +64,6 @@ console.log('nextProps :', nextProps);
|
||||
});
|
||||
|
||||
_resetPinCode = pin => new Promise((resolve, reject) => {
|
||||
console.log('_resetPinCode :', pin);
|
||||
const {
|
||||
currentAccount,
|
||||
dispatch,
|
||||
@ -87,7 +83,6 @@ console.log('nextProps :', nextProps);
|
||||
};
|
||||
|
||||
if (isOldPinVerified) {
|
||||
console.log('pinData updatePinCode :', pinData);
|
||||
updatePinCode(pinData).then((response) => {
|
||||
const _currentAccount = currentAccount;
|
||||
_currentAccount.local = response;
|
||||
@ -101,7 +96,6 @@ console.log('nextProps :', nextProps);
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
console.log('pinData verifyPinCode :', pinData);
|
||||
verifyPinCode(pinData)
|
||||
.then(() => {
|
||||
this.setState({ isOldPinVerified: true });
|
||||
@ -122,7 +116,6 @@ console.log('nextProps :', nextProps);
|
||||
});
|
||||
|
||||
_setFirstPinCode = pin => new Promise((resolve) => {
|
||||
console.log('_setFirstPinCode :', pin);
|
||||
const {
|
||||
currentAccount,
|
||||
dispatch,
|
||||
@ -154,7 +147,6 @@ console.log('nextProps :', nextProps);
|
||||
});
|
||||
|
||||
_verifyPinCode = pin => new Promise((resolve, reject) => {
|
||||
console.log('_verifyPinCode :', pin);
|
||||
const {
|
||||
currentAccount,
|
||||
dispatch,
|
||||
@ -192,15 +184,13 @@ console.log('nextProps :', nextProps);
|
||||
});
|
||||
});
|
||||
|
||||
_setPinCode = async (pin) => {
|
||||
_setPinCode = async (pin, isReset) => {
|
||||
const {
|
||||
intl,
|
||||
isReset,
|
||||
} = this.props;
|
||||
const {
|
||||
isExistUser, pinCode,
|
||||
} = this.state;
|
||||
console.log('this.props :', this.props);
|
||||
// For exist users
|
||||
if (isReset) return this._resetPinCode(pin);
|
||||
if (isExistUser) return this._verifyPinCode(pin);
|
||||
@ -209,7 +199,6 @@ console.log('this.props :', this.props);
|
||||
if (pinCode === pin) return this._setFirstPinCode(pin);
|
||||
|
||||
if (!pinCode) {
|
||||
console.log('1 :', pinCode);
|
||||
// If the user is logging in for the first time, the user should set to pin
|
||||
await this.setState({
|
||||
informationText: intl.formatMessage({
|
||||
@ -219,7 +208,6 @@ console.log('this.props :', this.props);
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
console.log('2 :', pinCode);
|
||||
|
||||
await this.setState({
|
||||
informationText: intl.formatMessage({
|
||||
@ -238,15 +226,16 @@ console.log('this.props :', this.props);
|
||||
};
|
||||
|
||||
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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user