Merge pull request #1043 from esteemapp/bugfix/login

Bugfix/login
This commit is contained in:
uğur erdal 2019-08-13 12:24:19 +03:00 committed by GitHub
commit 02ff41847b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -1,5 +1,6 @@
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 { getUser } from './dsteem'; import { getUser } from './dsteem';
import { import {
@ -21,7 +22,7 @@ import { getSCAccessToken } from '../esteem/esteem';
// Constants // Constants
import AUTH_TYPE from '../../constants/authType'; import AUTH_TYPE from '../../constants/authType';
export const login = async (username, password) => { export const login = async (username, password, isPinCodeOpen) => {
let loginFlag = false; let loginFlag = false;
let avatar = ''; let avatar = '';
let authType = ''; let authType = '';
@ -74,7 +75,18 @@ export const login = async (username, password) => {
accessToken: '', accessToken: '',
}; };
account.local = userData; if (isPinCodeOpen) {
account.local = userData;
} else {
const resData = {
pinCode: Config.DEFAULT_PIN,
password,
};
const updatedUserData = await getUpdatedUserData(userData, resData);
account.local = updatedUserData;
account.local.avatar = avatar;
}
const authData = { const authData = {
isLoggedIn: true, isLoggedIn: true,
@ -83,7 +95,7 @@ export const login = async (username, password) => {
await setAuthStatus(authData); await setAuthStatus(authData);
// Save user data to Realm DB // Save user data to Realm DB
await setUserData(userData); await setUserData(account.local);
await updateCurrentUsername(account.name); await updateCurrentUsername(account.name);
return { ...account, password }; return { ...account, password };
} }

View File

@ -70,8 +70,9 @@ import lightTheme from '../../../themes/lightTheme';
// Workaround // Workaround
let previousAppState = 'background'; let previousAppState = 'background';
export const setPreviousAppState = () => { export const setPreviousAppState = () => {
setTimeout(() => { const appStateTimeout = setTimeout(() => {
previousAppState = AppState.currentState; previousAppState = AppState.currentState;
clearTimeout(appStateTimeout);
}, 2000); }, 2000);
}; };
@ -494,6 +495,7 @@ class ApplicationContainer extends Component {
return realmObject[0]; return realmObject[0];
} }
dispatch(updateCurrentAccount({}));
dispatch(activeApplication()); dispatch(activeApplication());
dispatch(isLoginDone()); dispatch(isLoginDone());

View File

@ -51,7 +51,7 @@ class LoginContainer extends PureComponent {
this.setState({ isLoading: true }); this.setState({ isLoading: true });
login(username, password) login(username, password, isPinCodeOpen)
.then(result => { .then(result => {
if (result) { if (result) {
dispatch(updateCurrentAccount({ ...result })); dispatch(updateCurrentAccount({ ...result }));