Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function* loginFlow(email: string, password: string) {
try {
// Make sure and clean all cookies known to us
yield CookieManager.clearAll()
// Here we go, login the user
const { id } = yield call(login, email, password)
// All good, let's proceed to main
Actions.reset('drawer')
// .. or to another scene if we got a deep link incoming
const initial = yield getInitialScene()
if (initial)
Actions.jump(initial.scene, initial.props)
// Save the validated email and password in the device's safe store
yield Keychain.setGenericPassword(email, password)
// If we came that far, unhide the splash screen
yield SplashScreen.hide()
// Signal our succesful login and broadcast our fresh token and session
yield put({type: LOGIN_SUCCESS, payload: {...getSession(), id}})
// Pull our bells
this.state.ds.on('error', (error, event, topic ) => {
console.log(error, event, topic);
Actions.reset('signin', {ds: this.state.ds, configurePush: this.props.configurePush})
})
GoogleSignin.configure({
export default function (code, statusText) {
switch (code) {
case 401:
//授权逻辑
if (Actions.currentScene !== 'LoginPage') {
Actions.reset("LoginPage");
}
return "未授权或授权失败";//401 Unauthorized
case 403:
Toast(I18n('noPower'));
return "403权限错误";
case 404:
//Toast(I18n('notFound'));
return "404错误";
case 410:
Toast(I18n('gone410'));
return "410错误";
case NETWORK_TIMEOUT:
//超时
Toast(I18n('netTimeout'));
return I18n('netTimeout');
default:
this.state.dataRecord.whenReady(() => {
if (!this.state.profileRecord.get("onboardingComplete")) {
Actions.onboard({ds: this.props.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.props.configurePush});
} else {
var configurePush = this.props.configurePush.bind(this)
configurePush()
Actions.reset('drawer', {ds: this.props.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.props.configurePush});
Actions.home({ds: this.props.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.props.configurePush});
}
})
})
this.state.dataRecord.whenReady(() => {
if (!this.state.profileRecord.get("onboardingComplete")) {
Actions.reset('onboard', {ds: this.props.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.props.configurePush});
} else {
var configurePush = this.props.configurePush.bind(this)
configurePush()
Actions.reset('drawer', {ds: this.props.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.props.configurePush});
Actions.home({ds: this.props.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.props.configurePush});
}
})
})
setTimeout(() => {
Actions.reset('drawer')
if (initial)
Actions.jump(initial.scene, initial.props)
SplashScreen.hide()
}, 100)
this.state.dataRecord.whenReady(() => {
if (!this.state.profileRecord.get("onboardingComplete")) {
Actions.onboard({ ds: this.state.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.configurePush});
} else {
this.configurePush();
Actions.reset('drawer', { ds: this.state.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.configurePush });
Actions.home({ ds: this.state.ds, username: this.state.username, profileRecord: this.state.profileRecord, dataRecord: this.state.dataRecord, configurePush: this.configurePush });
}
})
})
setTimeout(() => {
Actions.reset('login');
}, 100);
};
handleSignOut = () => {
this.props.authLogout();
Actions.reset('loginScreen');
};
componentDidUpdate(prevProps) {
if (this.props.registered) Actions.reset('home');
}