0
This function is triggered by clicking the Login button:
export const loginUser = ({ email, password }) => {
return (dispatch) => {
dispatch({ type: LOGIN_USER });
firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL)
.then(() => {
firebase.auth().signInWithEmailAndPassword(email, password)
.then(user => {
firebase.database().ref('/admins').once('value')
.then(snapshot => {
const admins = _.map(snapshot.val(), (val, uid) => {
return { ...val, uid };
});
if (admins.some((item) => item.s_email === email)) {
typeAdmin(dispatch);
} else typeStudent(dispatch);
loginUserSuccess(dispatch, user);
});
}).catch(() => loginUserFail(dispatch));
});
};
};
Current Behavior
When leaving the application and back it is necessary to relocate to access the data of the currentUser.
Expected Behavior
When leaving the application keep the currentUser of the session and back nothing have been lost.
Thank you very much, that solution worked. I chose to store the user status for Asyncstorage, so I keep the information even if the application is closed. I voted -1 in your comment unintentionally and I’m not managing to change. Thanks for the help
– Lucas Katayama