-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 { try {
const response = await http.post('/user/login', data); const response = await http.post('/user/login', data);
http.defaults.headers.common['Authorization'] = response.data.token; if (response.status === 200){
await dispatch('setBasicData', response.data ); http.defaults.headers.common['Authorization'] = response.data.token;
await dispatch('setBasicData', response.data );
delete response.data.token; delete response.data.token;
delete response.data.roles; delete response.data.roles;
}
return response; return response;
} }

View File

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