mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-01-23 22:58:35 +01:00
Better errors handling for user controller
This commit is contained in:
parent
289b36d9d0
commit
efc3f5d61e
@ -24,7 +24,7 @@ public function login(Request $request)
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return response()->json(['error' => $validator->errors()], 400);
|
return response()->json(['validation' => $validator->errors()], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$credentials = [
|
$credentials = [
|
||||||
@ -93,7 +93,7 @@ public function register(Request $request)
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return response()->json(['error' => $validator->errors()], 400);
|
return response()->json(['validation' => $validator->errors()], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$input = $request->all();
|
$input = $request->all();
|
||||||
|
2
resources/js/app.js
vendored
2
resources/js/app.js
vendored
@ -67,7 +67,7 @@ const router = new VueRouter({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/error',
|
path: '/error',
|
||||||
name: 'GenericError',
|
name: 'genericError',
|
||||||
component: NotFound,
|
component: NotFound,
|
||||||
props: true
|
props: true
|
||||||
},
|
},
|
||||||
|
@ -183,7 +183,10 @@
|
|||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.response.status === 404) {
|
if (error.response.status === 404) {
|
||||||
this.$router.push({name: '404', params: { err : error.response }});
|
this.$router.push({name: '404', params: { err : error.response.data.error }});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.$router.push({ name: 'genericError', params: { err: error.response.data.message } });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -214,7 +217,7 @@
|
|||||||
this.$router.go('/login');
|
this.$router.go('/login');
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.$router.push({ name: 'error' });
|
this.$router.push({ name: 'genericError', params: { err: error.response.data.message } });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
<p class="error-generic"></p>
|
<p class="error-generic"></p>
|
||||||
<p>{{ $t('errors.error_occured') }}<router-link :to="{ name: 'accounts' }" class="is-text has-text-white">{{ $t('errors.refresh') }}</router-link></p>
|
<p>{{ $t('errors.error_occured') }}<router-link :to="{ name: 'accounts' }" class="is-text has-text-white">{{ $t('errors.refresh') }}</router-link></p>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="debugMode == 'development'">
|
<!-- <div v-if="debugMode == 'development'"> -->
|
||||||
<p v-if="debug" class="debug">
|
<p v-if="debug" class="debug">
|
||||||
<code>
|
<code>
|
||||||
{{ debug }}
|
{{ debug }}
|
||||||
</code>
|
</code>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
<!-- </div> -->
|
||||||
</modal>
|
</modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -34,7 +34,7 @@
|
|||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
ShowModal : true,
|
ShowModal : true,
|
||||||
debug : this.err ? this.err.data : null,
|
debug : this.err ? this.err : null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -62,11 +62,15 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.response.status === 400) {
|
console.log(error.response);
|
||||||
this.errors = error.response.data.error
|
if( error.response.status === 401 ) {
|
||||||
|
this.errors['password'] = [ this.$t('auth.forms.password_do_not_match') ]
|
||||||
|
}
|
||||||
|
else if( error.response.data.validation ) {
|
||||||
|
this.errors = error.response.data.validation
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.errors['password'] = [ this.$t('auth.forms.passwords_do_not_match') ]
|
this.$router.push({ name: 'genericError', params: { err: error.response.data.message } });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.$router.push({ name: 'error', params: { err: error.response.message } });
|
this.$router.push({ name: 'genericError', params: { err: error.response.data.message } });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -100,7 +100,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.errors = error.response.data.error
|
this.errors = error.response.data.validation
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
2
resources/js/vue-i18n-locales.generated.js
vendored
2
resources/js/vue-i18n-locales.generated.js
vendored
@ -16,7 +16,7 @@ export default {
|
|||||||
"confirm_password": "Confirm password",
|
"confirm_password": "Confirm password",
|
||||||
"dont_have_account_yet": "Don't have your account yet?",
|
"dont_have_account_yet": "Don't have your account yet?",
|
||||||
"already_register": "Already registered?",
|
"already_register": "Already registered?",
|
||||||
"passwords_do_not_match": "Passwords do not match"
|
"password_do_not_match": "Password do not match"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"commons": {
|
"commons": {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
'confirm_password' => 'Confirm password',
|
'confirm_password' => 'Confirm password',
|
||||||
'dont_have_account_yet' => 'Don\'t have your account yet?',
|
'dont_have_account_yet' => 'Don\'t have your account yet?',
|
||||||
'already_register' => 'Already registered?',
|
'already_register' => 'Already registered?',
|
||||||
'passwords_do_not_match' => 'Passwords do not match',
|
'password_do_not_match' => 'Password do not match',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user