Skip to content

Commit

Permalink
fully translate auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Jullian committed Dec 22, 2018
1 parent 690c695 commit 124c1ab
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 39 deletions.
3 changes: 3 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
</script>

<style>
body {
user-select: none;
}
</style>

</html>
38 changes: 17 additions & 21 deletions app/modules/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ const auth = {
tooggleMethod () {
if (!isSignUp) {
document.getElementById('conf_pass_textbox').style.display = 'block'
document.querySelector('.methodeBtn').innerHTML = 'SIGNUP'
document.getElementById('methodText').innerHTML = 'Signup'
document.querySelector('.askOtherMethode').innerHTML = `YOU HAVE ALREADY AN ACCOUNT ? <a href="#" onclick="auth.tooggleMethod()" class="link">LOG-IN</a> YOU HERE`
document.querySelector('.methodeBtn').innerHTML = lang('AUTH_SIGNUP').toUpperCase()
document.getElementById('methodText').innerHTML = lang('AUTH_SIGNUP')
document.querySelector('.askOtherMethode').innerHTML = lang('AUTH_ASK_FOR_SIGNIN')
isSignUp = true
} else {
document.getElementById('conf_pass_textbox').style.display = 'none'
document.querySelector('.methodeBtn').innerHTML = 'SIGNIN'
document.getElementById('methodText').innerHTML = 'Signin'
document.querySelector('.askOtherMethode').innerHTML = `YOU DON'T HAVE ANY ACCOUNT ? <a href="#" onclick="auth.tooggleMethod()" class="link">SIGN-UP</a> HERE`
document.querySelector('.methodeBtn').innerHTML = lang('AUTH_SIGNIN').toUpperCase()
document.getElementById('methodText').innerHTML = lang('AUTH_SIGNIN')
document.querySelector('.askOtherMethode').innerHTML = lang('AUTH_ASK_FOR_SIGNUP')
isSignUp = false
}
},
Expand Down Expand Up @@ -52,14 +52,13 @@ const auth = {

if (emailTextBox !== "" && emailTextBox.includes('@') && emailTextBox.includes('.')) {
if (passwordTextBox !== "") {
if (passwordTextBox.length > 8) {
if (passwordTextBox === confPasswordTextBox) {

let body = {
email: emailTextBox,
password: passwordTextBox
}

fetch(`${config.api}/auth/signup`, {
method: 'post',
body: JSON.stringify(body),
Expand All @@ -74,23 +73,20 @@ const auth = {
this.closeView()

} else if (data.message === 'AUTH_BAD_PASSWORD') {
this.setError('Wrong password')
this.setError(lang('AUTH_BAD_PASSWORD'))
} else if (data.message === 'AUTH_USER_NOT_FOUND') {
this.setError('User not found')
this.setError(lang('AUTH_USER_NOT_FOUND'))
}
})

} else {
this.setError('password do not match')
this.setError(lang('AUTH_PASSWORD_DONT_MATCH'))
}
} else {
this.setError('password must be more than 8 char')
}
} else {
this.setError('password mus be set')
this.setError(lang('AUTH_INVALID_PASSWORD'))
}
} else {
this.setError('Bad email')
this.setError(lang('AUTH_INVALID_EMAIL'))
}
},

Expand All @@ -116,7 +112,7 @@ const auth = {
// To uncomment
/*
if (nobodySaveTheWorld) {
let years = 2018
let years = 2019
while (years < 2074) {
console.log('work')
years++
Expand All @@ -133,17 +129,17 @@ const auth = {
this.closeView()

} else if (data.message === 'AUTH_BAD_PASSWORD') {
this.setError('Wrong password')
this.setError(lang('AUTH_BAD_PASSWORD'))
} else if (data.message === 'AUTH_USER_NOT_FOUND') {
this.setError('User not found')
this.setError(lang('AUTH_USER_NOT_FOUND'))
}
})

} else {
this.setError('password mus be set')
this.setError(lang('AUTH_INVALID_PASSWORD'))
}
} else {
this.setError('Bad email')
this.setError(lang('AUTH_INVALID_EMAIL'))
}
},

Expand Down
12 changes: 6 additions & 6 deletions app/modules/modales.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,27 @@ const modales = {
inputs.push(
'<div class="vex-custom-field-wrapper">',
'<div class="vex-custom-input-wrapper">',
'<input name="oldPassword" type="password" id="oldPassword" placeholder="Old password" />',
'<input name="newPassword" type="password" id="newPassword" placeholder="New password" />',
'<input name="confirmNewPassword" type="password" id="confirmNewPassword" placeholder="Confirm password" />',
`<input name="oldPassword" type="password" id="oldPassword" placeholder="${lang('AUTH_OLD_PASSWORD')}" />`,
`<input name="newPassword" type="password" id="newPassword" placeholder="${lang('AUTH_NEW_PASSWORD')}" />`,
`<input name="confirmNewPassword" type="password" id="confirmNewPassword" placeholder="${lang('AUTH_CONF_PASSWORD')}" />`,
'</div>',
'</div>'
)

vex.dialog.buttons.YES.text = lang('CONTINUE_BUTTON')
vex.dialog.buttons.NO.text = lang('CANCEL_BUTTON')
vex.dialog.open({
message: 'change password',
message: lang('AUTH_CHANGE_PASSWORD'),
input: inputs.join(''),
callback: (data) => {
if (data && data.oldPassword !== undefined && data.newPassword !== undefined) {
if (data.newPassword === data.confirmNewPassword) {
callback(data.oldPassword, data.newPassword)
} else {
alert('passwords d\'ont match')
alert(lang('AUTH_PASSWORD_DONT_MATCH'))
}
} else {
alert('Bad password')
alert(lang('AUTH_INVALID_PASSWORD'))
}
}
})
Expand Down
20 changes: 10 additions & 10 deletions app/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const settings = {
document.getElementById('accountTitle').innerHTML = lang('SETTINGS_ACCOUNT')
document.getElementById('accountStatus').innerHTML = lang('SETTINGS_ACCOUNT_STATUS')
document.getElementById('accountSettings').innerHTML = lang('SETTINGS_ACCOUNT_PASSWORD')
document.getElementById('logoutButton').value = lang('AUTH_LOGOUT').toUpperCase()
document.getElementById('signinButton').value = lang('AUTH_SIGNIN').toUpperCase()
document.querySelector('.version').innerHTML = `VERSION ${require('electron').remote.app.getVersion()}`
},

Expand Down Expand Up @@ -298,16 +300,14 @@ const settings = {
}).then(res => res.json()).catch((e) => {
alert(`error : ${e}`)
}).then((data) => {
console.log(data)
if (data.message === 'success') {
alert(`Success ! an email was send to : ${data.email}`)
this.logout()
} else if (data.message === "BAD_PASSWORD") {
alert('bad password')
} else {
alert(`error with the server`)
}
})
if (data.message === 'success') {
this.logout()
} else if (data.message === "BAD_PASSWORD") {
alert(lang('AUTH_BAD_PASSWORD'))
} else {
alert(lang('AUTH_SERVER_ERROR'))
}
})

})
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ <h1 id="accountTitle"></h1>
<div class="content">
<div class="section gray">
<p id="accountStatus">Stat</p>
<input onclick="settings.logout()" type="button" name="logout" class="btn-text" value="LOG OUT" />
<input onclick="EventsEmitter.emit('SHOW_AUTH')" type="button" name="singin" class="btn-text" value="SIGN IN" />
<input onclick="settings.logout()" type="button" name="logout" id="logoutButton" class="btn-text" value="LOG OUT" />
<input onclick="EventsEmitter.emit('SHOW_AUTH')" type="button" id="signinButton" name="singin" class="btn-text" value="SIGN IN" />
</div>

<div class="section white">
Expand Down
16 changes: 16 additions & 0 deletions lang/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@
{"value": "SETTINGS_ACCOUNT_STATUS", "message": "Status"},
{"value": "SETTINGS_ACCOUNT_PASSWORD", "message": "Change password"},

{"value": "AUTH_SIGNUP", "message": "Signup"},
{"value": "AUTH_LOGOUT", "message": "Logout"},
{"value": "AUTH_SIGNIN", "message": "Signin"},
{"value": "AUTH_ASK_FOR_SIGNUP", "message": "YOU DON'T HAVE ANY ACCOUNT ? <a href='#' onclick='auth.tooggleMethod()' class='link'>SIGN-UP</a> HERE"},
{"value": "AUTH_ASK_FOR_SIGNIN", "message": "YOU HAVE ALREADY AN ACCOUNT ? <a href='#' onclick='auth.tooggleMethod()' class='link'>LOG-IN</a> YOU HERE"},
{"value": "AUTH_BAD_PASSWORD", "message": "Bad password"},
{"value": "AUTH_USER_NOT_FOUND", "message": "User not found"},
{"value": "AUTH_PASSWORD_DONT_MATCH", "message": "Passwords do not match"},
{"value": "AUTH_SERVER_ERROR", "message": "A problem has occurred with the authentication server"},
{"value": "AUTH_OLD_PASSWORD", "message": "Old password"},
{"value": "AUTH_NEW_PASSWORD", "message": "New password"},
{"value": "AUTH_CONF_PASSWORD", "message": "Confirm password"},
{"value": "AUTH_CHANGE_PASSWORD", "message": "change the password"},
{"value": "AUTH_INVALID_PASSWORD", "message": "Please enter a valid password"},
{"value": "AUTH_INVALID_EMAIL", "message": "Please enter a valid email"},

{"value": "CONTINUE_BUTTON", "message": "continue"},
{"value": "CANCEL_BUTTON", "message": "cancel"},
{"value": "SEARCH_BUTTON", "message": "Search"},
Expand Down
16 changes: 16 additions & 0 deletions lang/fr_FR/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@
{"value": "SETTINGS_ACCOUNT_STATUS", "message": "Statut"},
{"value": "SETTINGS_ACCOUNT_PASSWORD", "message": "Changer le mot de passe"},

{"value": "AUTH_SIGNUP", "message": "Inscription"},
{"value": "AUTH_LOGOUT", "message": "Déconnexion"},
{"value": "AUTH_SIGNIN", "message": "Connexion"},
{"value": "AUTH_ASK_FOR_SIGNUP", "message": "VOUS N'AVEZ PAS DE COMPTE ? <a href='#' onclick='auth.tooggleMethod()' class='link'>INSCRIVE VOUS</a> ICI"},
{"value": "AUTH_ASK_FOR_SIGNIN", "message": "VOUS AVEZ DEJA UN COMPTE ? <a href='#' onclick='auth.tooggleMethod()' class='link'>CONNECTER VOUS</a> ICI"},
{"value": "AUTH_BAD_PASSWORD", "message": "Mauvais mot de passe"},
{"value": "AUTH_USER_NOT_FOUND", "message": "Utilisateur introuvable"},
{"value": "AUTH_PASSWORD_DONT_MATCH", "message": "Les mot de passes ne correspondent pas"},
{"value": "AUTH_SERVER_ERROR", "message": "Un problème est survenue avec le serveur d'authentification"},
{"value": "AUTH_OLD_PASSWORD", "message": "Ancien mot de passe"},
{"value": "AUTH_NEW_PASSWORD", "message": "Nouveau mot de passe"},
{"value": "AUTH_CONF_PASSWORD", "message": "Confirmer le mot de passe"},
{"value": "AUTH_CHANGE_PASSWORD", "message": "Changer le mot de passe"},
{"value": "AUTH_INVALID_PASSWORD", "message": "Veuillez entrer un mot de passe valide"},
{"value": "AUTH_INVALID_EMAIL", "message": "Veuillez entrer un email valide"},

{"value": "CONTINUE_BUTTON", "message": "continuer"},
{"value": "CANCEL_BUTTON", "message": "annuler"},
{"value": "SEARCH_BUTTON", "message": "Rechercher"},
Expand Down

0 comments on commit 124c1ab

Please sign in to comment.