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