-Fix login user data message error.
This commit is contained in:
Juan Carlos Ruvalcaba 2021-09-06 21:11:20 -07:00
parent 315b35c3fe
commit fe4d913190
2 changed files with 15 additions and 11 deletions

View File

@ -48,11 +48,13 @@ const user = createStore({
try {
const response = await http.post('/user/login', data);
http.defaults.headers.common['Authorization'] = response.data.token;
await dispatch('setBasicData', response.data );
if (response.status === 200){
http.defaults.headers.common['Authorization'] = response.data.token;
await dispatch('setBasicData', response.data );
delete response.data.token;
delete response.data.roles;
delete response.data.token;
delete response.data.roles;
}
return response;
}

View File

@ -65,15 +65,17 @@ export default (props, { $f7, $on, $update, $f7router }) => {
};
const result = await user.dispatch('logIn', data);
$f7.preloader.hide();
if (result.status === 200){
$f7router.navigate('/');
$f7.toast.show( { text: "Ha iniciado sesión." });
}
else{
$f7.toast.show( { text: result.message });
if (result.status !== undefined && result.status !== 200){
$f7.toast.show( { text: result.data.messages.error } );
$f7.preloader.hide();
return;
}
$f7.preloader.hide();
$f7router.navigate('/');
$f7.toast.show( { text: "Ha iniciado sesión." });
}
catch (error) {
$f7.preloader.hide();