Refactor Site-Wide Data
This commit is contained in:
parent
6cec3efbd7
commit
66e3615310
1 changed files with 81 additions and 79 deletions
|
@ -8,83 +8,85 @@
|
||||||
<h2>Modifier mon mot de passe</h2>
|
<h2>Modifier mon mot de passe</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{if .Common.ErrorMessage}}
|
{{if .Common.ErrorMessage}}
|
||||||
<div class="alert alert-danger mt-4">Impossible d'effectuer la modification.
|
<div class="alert alert-danger mt-4">Impossible d'effectuer la modification.
|
||||||
<div style="font-size: 0.8em">{{ .Common.ErrorMessage }}</div>
|
<div style="font-size: 0.8em">{{ .Common.ErrorMessage }}</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Common.Success}}
|
{{if .Common.Success}}
|
||||||
<div class="alert alert-success mt-4">
|
<div class="alert alert-success mt-4">
|
||||||
Nouveau mot de passe enregistré.
|
Nouveau mot de passe enregistré.
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form method="POST" class="mt-4" onsubmit="javascript:var password = document.getElementById('password');var password2 = document.getElementById('password2'); if (password.value != password2.value) {alert('Les maux de passe ne sont pas identiques entre l\'initial et la confirmation.');return false;}; message = checkPasswordStrength(password.value); if (message) {alert(message);return false}else{return true;}">
|
<form method="POST" class="mt-4"
|
||||||
<div class="form-group">
|
onsubmit="javascript:var password = document.getElementById('password');var password2 = document.getElementById('password2'); if (password.value != password2.value) {alert('Les maux de passe ne sont pas identiques entre l\'initial et la confirmation.');return false;}; message = checkPasswordStrength(password.value); if (message) {alert(message);return false}else{return true;}">
|
||||||
<label for="password">Nouveau mot de passe :</label>
|
<div class="form-group">
|
||||||
<input type="password" id="password" name="password" class="form-control" minlength="8" required />
|
<label for="password">Nouveau mot de passe :</label>
|
||||||
</div>
|
<input type="password" id="password" name="password" class="form-control" minlength="8" required />
|
||||||
{if .DataTooShortError}}
|
</div>
|
||||||
<div class="alert alert-warning">
|
{if .Data.TooShortError }}
|
||||||
Le mot de passe choisi est trop court (minimum 8 caractères).
|
<div class="alert alert-warning">
|
||||||
</div>
|
Le mot de passe choisi est trop court (minimum 8 caractères).
|
||||||
{{end}}
|
</div>
|
||||||
<div class="form-group">
|
{{end}}
|
||||||
<label for="password2">Répéter le mot de passe :</label>
|
<div class="form-group">
|
||||||
<input type="password" id="password2" name="password2" class="form-control" />
|
<label for="password2">Répéter le mot de passe :</label>
|
||||||
</div>
|
<input type="password" id="password2" name="password2" class="form-control" />
|
||||||
{if .DataNoMatchError}}
|
</div>
|
||||||
<div class="alert alert-warning">
|
{if .Data.NoMatchError }}
|
||||||
Les deux mots de passe entrés ne correspondent pas.
|
<div class="alert alert-warning">
|
||||||
</div>
|
Les deux mots de passe entrés ne correspondent pas.
|
||||||
{{end}}
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Changer de mot de passe</button>
|
{{end}}
|
||||||
</form>
|
<button type="submit" class="btn btn-primary">Changer de mot de passe</button>
|
||||||
{{end}}
|
</form>
|
||||||
<script>
|
{{end}}
|
||||||
function checkPasswordStrength(password) {
|
<script>
|
||||||
// Initialize variables
|
function checkPasswordStrength(password) {
|
||||||
var strength = 0;
|
// Initialize variables
|
||||||
var tips = "";
|
var strength = 0;
|
||||||
|
var tips = "";
|
||||||
// Check password length
|
|
||||||
if (password.length < 8) {
|
// Check password length
|
||||||
tips += "Au minimum 8 chars dans votre mot de passe svp. ";
|
if (password.length < 8) {
|
||||||
} else {
|
tips += "Au minimum 8 chars dans votre mot de passe svp. ";
|
||||||
strength += 1;
|
} else {
|
||||||
}
|
strength += 1;
|
||||||
|
}
|
||||||
// Check for mixed case
|
|
||||||
if (password.match(/[a-z]/) && password.match(/[A-Z]/)) {
|
// Check for mixed case
|
||||||
strength += 1;
|
if (password.match(/[a-z]/) && password.match(/[A-Z]/)) {
|
||||||
} else {
|
strength += 1;
|
||||||
tips += "Merci d'utiliser des minuscules et majuscules. ";
|
} else {
|
||||||
}
|
tips += "Merci d'utiliser des minuscules et majuscules. ";
|
||||||
|
}
|
||||||
// Check for numbers
|
|
||||||
if (password.match(/\d/)) {
|
// Check for numbers
|
||||||
strength += 1;
|
if (password.match(/\d/)) {
|
||||||
} else {
|
strength += 1;
|
||||||
tips += "Merci d'inclure un chiffre. ";
|
} else {
|
||||||
}
|
tips += "Merci d'inclure un chiffre. ";
|
||||||
|
}
|
||||||
// Check for special characters
|
|
||||||
if (password.match(/[^a-zA-Z\d]/)) {
|
// Check for special characters
|
||||||
strength += 1;
|
if (password.match(/[^a-zA-Z\d]/)) {
|
||||||
} else {
|
strength += 1;
|
||||||
tips += "Inclure au moins un caractère spécial. ";
|
} else {
|
||||||
}
|
tips += "Inclure au moins un caractère spécial. ";
|
||||||
|
}
|
||||||
// Return results
|
|
||||||
if (strength < 2) {
|
// Return results
|
||||||
return "Trop facile à déviner. " + tips;
|
if (strength < 2) {
|
||||||
} else if (strength === 2) {
|
return "Trop facile à déviner. " + tips;
|
||||||
return "Difficulté moyenne. " + tips;
|
} else if (strength === 2) {
|
||||||
} else if (strength === 3) {
|
return "Difficulté moyenne. " + tips;
|
||||||
return false; // "Difficile à craquer. " + tips;
|
} else if (strength === 3) {
|
||||||
} else {
|
return false; // "Difficile à craquer. " + tips;
|
||||||
return false; // "Mot de passe digne de ce nom. " + tips;
|
} else {
|
||||||
}
|
return false; // "Mot de passe digne de ce nom. " + tips;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
|
||||||
|
</script>
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
Loading…
Reference in a new issue