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
|
||||
|
||||
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({
|
||||
"message": `L'utilisateur #${fetchedUser.id} s'est connecté.`,
|
||||
"message": `L'utilisateur #${fetchedUser.name} s'est connecté.`,
|
||||
"code": 200,
|
||||
"user": fetchedUser,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
reject({
|
||||
"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"
|
||||
id="email"
|
||||
class="form-control"
|
||||
:class="{
|
||||
'is-invalid': errors.email || errors.login,
|
||||
'is-valid': submitted && !errors.email }"
|
||||
:class="{ 'is-invalid': errors.email || errors.login }"
|
||||
placeholder="john.doe@gmail.com"
|
||||
autocomplete="email">
|
||||
|
||||
@@ -145,10 +143,10 @@ export default {
|
||||
this.$router.push('/profil')
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.status === 404) {
|
||||
if (err.status != 500) {
|
||||
this.errors.email = err.data.error;
|
||||
} 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"
|
||||
:class="{
|
||||
'is-invalid': errors.name,
|
||||
'is-valid': submitted && !errors.name }"
|
||||
'is-valid': !errors.name }"
|
||||
type="text"
|
||||
id="username"
|
||||
class="form-control"
|
||||
@@ -38,7 +38,7 @@
|
||||
v-model="email"
|
||||
:class="{
|
||||
'is-invalid': errors.email,
|
||||
'is-valid': submitted && !errors.email }"
|
||||
'is-valid': !errors.email }"
|
||||
type="email"
|
||||
id="email"
|
||||
class="form-control"
|
||||
@@ -64,7 +64,7 @@
|
||||
<input
|
||||
:class="{
|
||||
'is-invalid': errors.password,
|
||||
'is-valid': submitted && !errors.password }"
|
||||
'is-valid': !errors.password }"
|
||||
v-model="password"
|
||||
type="password"
|
||||
id="password"
|
||||
@@ -78,7 +78,7 @@
|
||||
v-model="password_check"
|
||||
:class="{
|
||||
'is-invalid': errors.password_check || errors.password,
|
||||
'is-valid': submitted && !errors.password_check}"
|
||||
'is-valid': !errors.password_check}"
|
||||
type="password"
|
||||
id="password_check"
|
||||
class="form-control"
|
||||
@@ -156,16 +156,16 @@ export default {
|
||||
}
|
||||
|
||||
// Check if all inputs are valid without sending anything
|
||||
if (!userInput.name) {
|
||||
if (!userInput.user.name) {
|
||||
this.errors.name = "Vous devez renseigner un pseudonyme."
|
||||
}
|
||||
if (!userInput.mail) {
|
||||
if (!userInput.user.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."
|
||||
}
|
||||
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."
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user