Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request hedyorg#226 from Felienne/email-checks
Browse files Browse the repository at this point in the history
Email checks on signup
  • Loading branch information
Felienne authored Mar 20, 2021
2 parents da6fac3 + ca98310 commit fd5dc20
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 9 deletions.
4 changes: 3 additions & 1 deletion coursedata/texts/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Auth:
create_account_explanation: "Dein eigenes Konto erlaubt es dir, deine Programme zu speichern."
username: "Benutzername"
email: "Email"
email_repeat: "Wiederhole Email"
password: "Passwort"
password_repeat: "Wiederhole Passwort"
birth_year: "Geburtjahr (optional)"
Expand Down Expand Up @@ -75,7 +76,8 @@ Auth:
username_special: "Der Benutzername darf nicht `:` oder `@` enthalten."
please_password: "Bitte gib ein Passwort ein."
password_six: "Das Passwort muss aus mindestens sechs Zeichen bestehen."
repeat_match: "Das wiederholte Passwort stimmt nicht mit dem ersten überein."
repeat_match_email: "Das wiederholte Email stimmt nicht mit dem ersten überein."
repeat_match_password: "Das wiederholte Passwort stimmt nicht mit dem ersten überein."
valid_email: "Bitte eine gültige Email-Adresse eingeben."
valid_year: "Bitte ein Jahr eingeben zwischen 1900 und "
ajax_error: "Ein Fehler ist aufgetreten. Bitte nochmal versuchen."
Expand Down
4 changes: 3 additions & 1 deletion coursedata/texts/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Auth:
create_account_explanation: "Having your own account allows you to save your programs."
username: "Username"
email: "Email"
email_repeat: "Repeat email"
password: "Password"
password_repeat: "Repeat password"
birth_year: "Birth year (optional)"
Expand Down Expand Up @@ -75,7 +76,8 @@ Auth:
username_special: "Username cannot contain `:` or `@`."
please_password: "Please enter a password."
password_six: "Password must contain at least six characters."
repeat_match: "The repeated password does not match."
repeat_match_email: "The repeated email does not match."
repeat_match_password: "The repeated password does not match."
valid_email: "Please enter a valid email."
valid_year: "Please enter a year between 1900 and "
ajax_error: "There was an error, please try again."
Expand Down
4 changes: 3 additions & 1 deletion coursedata/texts/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Auth:
create_account_explanation: "Con tu cuenta puedes salvar tus programas."
username: "Usuario"
email: "Correo electrónico"
email_repeat: "Repetir correo electrónico"
password: "Contraseña"
password_repeat: "Repetir contraseña"
birth_year: "Año de nacimiento (opcional)"
Expand Down Expand Up @@ -75,7 +76,8 @@ Auth:
username_special: "El nombre de usuario no puede contener los caracteres `:` o `@`."
please_password: "Por favor ingresa una contraseña."
password_six: "La contraseña debe contener al menos seis caracteres."
repeat_match: "La contraseña repetida es distinta."
repeat_match_email: "El email repetido es distinto."
repeat_match_password: "La contraseña repetida es distinta."
valid_email: "Por favor ingresa una dirección de correo electrónico válida."
valid_year: "Por favor ingresa un año entre 1900 y "
ajax_error: "Hubo un error, por favor intenta nuevamente."
Expand Down
4 changes: 3 additions & 1 deletion coursedata/texts/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Auth:
create_account_explanation: "Avoir un compte te permettra de sauvegarder tes programmes."
username: "Identifiant"
email: "Adresse email"
email_repeat: "Confirmer adresse email"
password: "Mot de passe"
password_repeat: "Confirmer mot de passe"
birth_year: "Année de naissance (optionnel)"
Expand Down Expand Up @@ -75,7 +76,8 @@ Auth:
username_special: "L'identifiant ne pas pas contenir de `:` ou de `@`."
please_password: "Veuillez saisir un mot de passe."
password_six: "Le mot de passe doit contenir au moins six caractères."
repeat_match: "Les mots de passe ne sont pas identiques."
repeat_match_email: "Les email addresses ne sont pas identiques."
repeat_match_password: "Les mots de passe ne sont pas identiques."
valid_email: "Veuillez saisir une adresse email valide."
valid_year: "Veuillez saisir une année entre 1900 et 2021."
ajax_error: "Une erreur est survenue, merci de réessayer."
Expand Down
4 changes: 3 additions & 1 deletion coursedata/texts/it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Auth:
create_account_explanation: "Avere un account ti permette di salvare i tuoi programmi."
username: "Nome utente"
email: "Email"
email_repeat: "Ripeti email"
password: "Password"
password_repeat: "Ripeti password"
birth_year: "Anno di nascita (opzionale)"
Expand Down Expand Up @@ -75,7 +76,8 @@ Auth:
username_special: "Il nome utente non può contenere `:` o `@`."
please_password: "Per favore inserisci la password."
password_six: "La password deve contenere almeno sei caratteri"
repeat_match: "La password ripetuta non combacia."
repeat_match_email: "Il email ripetuto non combacia."
repeat_match_password: "La password ripetuta non combacia."
valid_email: "Per favore inserisci un'email valida."
valid_year: "Per favore inserisci un anno tra il 1900 e "
ajax_error: "C'è stato un problema, per favore riprova."
Expand Down
6 changes: 4 additions & 2 deletions coursedata/texts/nl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Auth:
create_account_explanation: "Met een account kun je je programma's opslaan."
username: "Gebruikersnaam"
email: "Email"
email_repeat: "Herhaal je email"
password: "Wachtwoord"
password_repeat: "Herhaal je wachtwoord"
birth_year: "Geboortejaar (optioneel)"
Expand Down Expand Up @@ -75,8 +76,9 @@ Auth:
username_special: "Er mag geen `:` of `@` in je gebruikersnaam zitten."
please_password: "Vul een wachtwoord in."
password_six: "Je wachtwoord moet minstens 6 letters hebben."
repeat_match: "De wachtwoorden zijn niet hetzelfde."
valid_email: "Vul een geldig wachtwoord in."
repeat_match_email: "De emails zijn niet hetzelfde."
repeat_match_password: "De wachtwoorden zijn niet hetzelfde."
valid_email: "Vul een geldig email in."
valid_year: "Het jaar moet later zijn dan 1900 en "
ajax_error: "Er is een fout opgetreden, probeer het nog eens."
please_username_email: "Vul een gebruikersnaam of email adres in."
Expand Down
4 changes: 3 additions & 1 deletion coursedata/texts/pt_br.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Auth:
create_account_explanation: "Having your own account allows you to save your programs."
username: "Username"
email: "Email"
email_repeat: "Repeat email"
password: "Password"
password_repeat: "Repeat password"
birth_year: "Birth year (optional)"
Expand Down Expand Up @@ -75,7 +76,8 @@ Auth:
username_special: "Username cannot contain `:` or `@`."
please_password: "Please enter a password."
password_six: "Password must contain at least six characters."
repeat_match: "The repeated password does not match."
repeat_match_email: "The repeated email does not match."
repeat_match_password: "The repeated password does not match."
valid_email: "Please enter a valid email."
valid_year: "Please enter a year between 1900 and "
ajax_error: "There was an error, please try again."
Expand Down
9 changes: 8 additions & 1 deletion static/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ window.auth = {
if (values.username.match (/:|@/)) return auth.error (auth.texts.username_special, 'username');
if (! values.password) return auth.error (auth.texts.please_password, 'password');
if (values.password.length < 6) return auth.error (auth.texts.password_six, 'password');
if (values.password !== values.password_repeat) return auth.error (auth.texts.repeat_match, 'psasword_repeat');
if (! values.email.match (/^(([a-zA-Z0-9_\.\-]+)@([\da-zA-Z\.\-]+)\.([a-zA-Z\.]{2,6})\s*)$/)) return auth.error (auth.texts.valid_email, 'email');
if (values.email !== values.email_repeat) return auth.error (auth.texts.repeat_match_email, 'email_repeat');
if (values.password !== values.password_repeat) return auth.error (auth.texts.repeat_match_password, 'password_repeat');
if (values.birth_year) {
values.birth_year = parseInt (values.birth_year);
if (! values.birth_year || values.birth_year < 1900 || values.birth_year > new Date ().getFullYear ()) return auth.error (auth.texts.valid_year + new Date ().getFullYear (), 'birth_year');
Expand Down Expand Up @@ -253,3 +254,9 @@ if (window.location.pathname === '/signup') {
else $ ('#username').val (login_username);
}
}

$ ('#email, #email_repeat').on ('cut copy paste', function (e) {
console.log ('DEBUG cut/copy/paste prevented', e);
e.preventDefault ();
return false;
});
3 changes: 3 additions & 0 deletions templates/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ <h4 class="text-blue-500">{{auth.create_account_explanation}}</h3>
<label>{{auth.email}}</label>
<input id="email" type="email">
<br><br>
<label>{{auth.email_repeat}}</label>
<input id="email_repeat" type="email">
<br><br>
<label>{{auth.password}}</label>
<input id="password" type=password>
<br><br>
Expand Down

0 comments on commit fd5dc20

Please sign in to comment.