mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-01-23 14:48:36 +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()) {
|
||||
return response()->json(['error' => $validator->errors()], 400);
|
||||
return response()->json(['validation' => $validator->errors()], 400);
|
||||
}
|
||||
|
||||
$credentials = [
|
||||
@ -93,7 +93,7 @@ public function register(Request $request)
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['error' => $validator->errors()], 400);
|
||||
return response()->json(['validation' => $validator->errors()], 400);
|
||||
}
|
||||
|
||||
$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',
|
||||
name: 'GenericError',
|
||||
name: 'genericError',
|
||||
component: NotFound,
|
||||
props: true
|
||||
},
|
||||
|
@ -183,7 +183,10 @@
|
||||
})
|
||||
.catch(error => {
|
||||
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');
|
||||
})
|
||||
.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>{{ $t('errors.error_occured') }}<router-link :to="{ name: 'accounts' }" class="is-text has-text-white">{{ $t('errors.refresh') }}</router-link></p>
|
||||
</div>
|
||||
<div v-if="debugMode == 'development'">
|
||||
<!-- <div v-if="debugMode == 'development'"> -->
|
||||
<p v-if="debug" class="debug">
|
||||
<code>
|
||||
{{ debug }}
|
||||
</code>
|
||||
</p>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
</modal>
|
||||
</div>
|
||||
</template>
|
||||
@ -34,7 +34,7 @@
|
||||
data(){
|
||||
return {
|
||||
ShowModal : true,
|
||||
debug : this.err ? this.err.data : null,
|
||||
debug : this.err ? this.err : null,
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -62,11 +62,15 @@
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.response.status === 400) {
|
||||
this.errors = error.response.data.error
|
||||
console.log(error.response);
|
||||
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 {
|
||||
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 => {
|
||||
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 => {
|
||||
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",
|
||||
"dont_have_account_yet": "Don't have your account yet?",
|
||||
"already_register": "Already registered?",
|
||||
"passwords_do_not_match": "Passwords do not match"
|
||||
"password_do_not_match": "Password do not match"
|
||||
}
|
||||
},
|
||||
"commons": {
|
||||
|
@ -28,7 +28,7 @@
|
||||
'confirm_password' => 'Confirm password',
|
||||
'dont_have_account_yet' => 'Don\'t have your account yet?',
|
||||
'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