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

View File

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

View File

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