mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
commit
02ff41847b
@ -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: '',
|
||||
};
|
||||
|
||||
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 = {
|
||||
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 };
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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 }));
|
||||
|
Loading…
Reference in New Issue
Block a user