Commit 8e09ce9a authored by quentin.vrel's avatar quentin.vrel

better error messages handling

parent 738cc65d
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
<div class="form-content"> <div class="form-content">
<text-input id="login" label="Pseudo"/> <text-input id="login" label="Pseudo"/>
<pwd-input id="password" label="Mot de passe"/> <pwd-input id="password" label="Mot de passe"/>
<error-message id="error-empty" errormessage="Tous les champs ne sont pas remplis." v-show="this.showNotFilledError"/>
<error-message id="error-credentials" errormessage="Identifiants incorrects, veuillez réessayer." v-show="this.showCredentialsError"/>
<error-message id="error-banned" errormessage="Votre compte est banni." v-show="this.showBanError"/>
</div> </div>
<div class="submit-buttons"> <div class="submit-buttons">
<svg-button id="validate" svg="/icons/validate.svg"/> <svg-button id="validate" svg="/icons/validate.svg"/>
...@@ -20,13 +23,15 @@ import PageTitle from '@/components/PageTitle.vue' ...@@ -20,13 +23,15 @@ import PageTitle from '@/components/PageTitle.vue'
import SvgButton from '@/components/SvgButton.vue' import SvgButton from '@/components/SvgButton.vue'
import TextInput from '@/components/form/TextInput.vue' import TextInput from '@/components/form/TextInput.vue'
import PwdInput from '@/components/form/PwdInput.vue' import PwdInput from '@/components/form/PwdInput.vue'
import ErrorMessage from '@/components/form/ErrorMessage.vue'
export default { export default {
name: 'Login', name: 'Login',
components: { components: {
PageTitle, PageTitle,
SvgButton, SvgButton,
TextInput, TextInput,
PwdInput PwdInput,
ErrorMessage
}, },
beforeCreate () { beforeCreate () {
if (localStorage.getItem('user') != null) { if (localStorage.getItem('user') != null) {
...@@ -36,10 +41,15 @@ export default { ...@@ -36,10 +41,15 @@ export default {
data() { data() {
return { return {
showNotFilledError : false, showNotFilledError : false,
showCredentialsError : false,
showBanError : false
} }
}, },
methods: { methods: {
onSubmit: async function(event){ onSubmit: async function(event){
this.showCredentialsError = false;
this.showBanError = false;
if (event.submitter.id=='back') { if (event.submitter.id=='back') {
this.$router.push('/'); this.$router.push('/');
} }
...@@ -73,6 +83,20 @@ export default { ...@@ -73,6 +83,20 @@ export default {
localStorage.setItem('user', JSON.stringify(json)); localStorage.setItem('user', JSON.stringify(json));
this.$router.push('lobby'); this.$router.push('lobby');
} }
else{
switch (response.status) {
case 422:
this.showCredentialsError = true;
break;
case 402:
this.showBanError = true;
break;
default:
this.showCredentialsError = true;
break;
}
}
} }
} }
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<error-message id="error-password" errormessage="Les mots de passe ne correspondent pas." v-show="this.showPwdError"/> <error-message id="error-password" errormessage="Les mots de passe ne correspondent pas." v-show="this.showPwdError"/>
<error-message id="error-mail" errormessage="Le mail rentré n'est pas valide" v-show="this.showMailError"/> <error-message id="error-mail" errormessage="Le mail rentré n'est pas valide" v-show="this.showMailError"/>
<error-message id="error-back" errormessage="Ce pseudo est déjà pris." v-show="this.showPseudoError"/> <error-message id="error-back" errormessage="Ce pseudo est déjà pris." v-show="this.showPseudoError"/>
<error-message id="error-back" errormessage="Tous les champs obligatoires ne sont pas remplis." v-show="this.showNotFilledError"/> <error-message id="error-empty" errormessage="Tous les champs obligatoires ne sont pas remplis." v-show="this.showNotFilledError"/>
</div> </div>
<div class="submit-buttons"> <div class="submit-buttons">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment