Merge pull request #29 from AlexisNP/issues/verifban
API user verifications
This commit is contained in:
@@ -145,11 +145,23 @@ class UserRepository {
|
|||||||
delete fetchedUser.password
|
delete fetchedUser.password
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
|
if (fetchedUser.banned) {
|
||||||
|
reject({
|
||||||
|
"message": `L'utilisateur #${fetchedUser.name} a été banni, la connexion est impossible.`,
|
||||||
|
"code": 403
|
||||||
|
})
|
||||||
|
} else if (!fetchedUser.verified) {
|
||||||
|
reject({
|
||||||
|
"message": `L'utilisateur #${fetchedUser.name} n'as pas été vérifié, le compte doit être activé avant la connexion.`,
|
||||||
|
"code": 401
|
||||||
|
})
|
||||||
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
"message": `L'utilisateur #${fetchedUser.id} s'est connecté.`,
|
"message": `L'utilisateur #${fetchedUser.name} s'est connecté.`,
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"user": fetchedUser,
|
"user": fetchedUser,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
reject({
|
reject({
|
||||||
"message": "Les informations de connexions sont erronées.",
|
"message": "Les informations de connexions sont erronées.",
|
||||||
|
|||||||
18
client/src/components/user/profile/update-form.vue
Normal file
18
client/src/components/user/profile/update-form.vue
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<form>
|
||||||
|
<div>Update profile for {{ user.name }}</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'update-form',
|
||||||
|
props: {
|
||||||
|
user: Object,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -13,9 +13,7 @@
|
|||||||
type="email"
|
type="email"
|
||||||
id="email"
|
id="email"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
:class="{
|
:class="{ 'is-invalid': errors.email || errors.login }"
|
||||||
'is-invalid': errors.email || errors.login,
|
|
||||||
'is-valid': submitted && !errors.email }"
|
|
||||||
placeholder="john.doe@gmail.com"
|
placeholder="john.doe@gmail.com"
|
||||||
autocomplete="email">
|
autocomplete="email">
|
||||||
|
|
||||||
@@ -145,10 +143,10 @@ export default {
|
|||||||
this.$router.push('/profil')
|
this.$router.push('/profil')
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.status === 404) {
|
if (err.status != 500) {
|
||||||
this.errors.email = err.data.error;
|
this.errors.email = err.data.error;
|
||||||
} else {
|
} else {
|
||||||
this.errors.login = "Une erreur inconnue est survenue, rééssayez plus tard.";
|
this.errors.login = err.data.error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
v-model="name"
|
v-model="name"
|
||||||
:class="{
|
:class="{
|
||||||
'is-invalid': errors.name,
|
'is-invalid': errors.name,
|
||||||
'is-valid': submitted && !errors.name }"
|
'is-valid': !errors.name }"
|
||||||
type="text"
|
type="text"
|
||||||
id="username"
|
id="username"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
v-model="email"
|
v-model="email"
|
||||||
:class="{
|
:class="{
|
||||||
'is-invalid': errors.email,
|
'is-invalid': errors.email,
|
||||||
'is-valid': submitted && !errors.email }"
|
'is-valid': !errors.email }"
|
||||||
type="email"
|
type="email"
|
||||||
id="email"
|
id="email"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
<input
|
<input
|
||||||
:class="{
|
:class="{
|
||||||
'is-invalid': errors.password,
|
'is-invalid': errors.password,
|
||||||
'is-valid': submitted && !errors.password }"
|
'is-valid': !errors.password }"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
type="password"
|
type="password"
|
||||||
id="password"
|
id="password"
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
v-model="password_check"
|
v-model="password_check"
|
||||||
:class="{
|
:class="{
|
||||||
'is-invalid': errors.password_check || errors.password,
|
'is-invalid': errors.password_check || errors.password,
|
||||||
'is-valid': submitted && !errors.password_check}"
|
'is-valid': !errors.password_check}"
|
||||||
type="password"
|
type="password"
|
||||||
id="password_check"
|
id="password_check"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@@ -156,16 +156,16 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if all inputs are valid without sending anything
|
// Check if all inputs are valid without sending anything
|
||||||
if (!userInput.name) {
|
if (!userInput.user.name) {
|
||||||
this.errors.name = "Vous devez renseigner un pseudonyme."
|
this.errors.name = "Vous devez renseigner un pseudonyme."
|
||||||
}
|
}
|
||||||
if (!userInput.mail) {
|
if (!userInput.user.mail) {
|
||||||
this.errors.email = "Vous devez renseigner une addresse mail."
|
this.errors.email = "Vous devez renseigner une addresse mail."
|
||||||
}
|
}
|
||||||
if (!userInput.password) {
|
if (!userInput.user.password) {
|
||||||
this.errors.password = "Vous devez renseigner un mot de passe."
|
this.errors.password = "Vous devez renseigner un mot de passe."
|
||||||
}
|
}
|
||||||
if ((userInput.password.localeCompare(this.password_check)) != 0) {
|
if ((userInput.user.password.localeCompare(this.password_check)) != 0) {
|
||||||
this.errors.password_check = "Les mots de passe ne correspondent pas."
|
this.errors.password_check = "Les mots de passe ne correspondent pas."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user