Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect happening before login is finished processing #78

Merged
merged 6 commits into from
Feb 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ _site/
.bundle/
vendor/
*.iml
.idea
packages
*.lock
13 changes: 8 additions & 5 deletions client/i18n/english.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ en =
minChar: "7 character minimum password."
pwOneLetter: "Password requires 1 letter."
pwOneDigit: "Password must have at least one digit."
uernameRequired: "Username is required"
emailRequired: "Email is required"
signupCodeRequired: "Signup code is required"
signupCodeIncorrect: "Signup code is incorrect"
unknown: "Unknown error"
usernameRequired: "Username is required."
emailRequired: "Email is required."
signupCodeRequired: "Signup code is required."
signupCodeIncorrect: "Signup code is incorrect."
userValidationFailed: "User validation failed."
emailAlreadyExists: "Email already exists."
usernameAlreadyExists: "Username already exists."
unknown: "Unknown error."

i18n.map "en", en
13 changes: 8 additions & 5 deletions client/i18n/german.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ de =
minChar: "Passwort muss mindesten 7 Zeichen lang sein."
pwOneLetter: "Passwort muss mindestens einen Buchstaben enthalten."
pwOneDigit: "Passwort muss mindestens eine Ziffer enthalten."
uernameRequired: "Benutzername benötigt"
emailRequired: "E-Mail benötigt"
signupCodeRequired: "Registrierungscode benötigt"
signupCodeIncorrect: "Registrierungscode ungültig"
unknown: "Unbekannter Fehler"
usernameRequired: "Benutzername benötigt."
emailRequired: "E-Mail benötigt."
signupCodeRequired: "Registrierungscode benötigt."
signupCodeIncorrect: "Registrierungscode ungültig."
userValidationFailed: "[DE] User validation failed."
emailAlreadyExists: "[DE] Email already exists."
usernameAlreadyExists: "[DE] Username already exists."
unknown: "Unbekannter Fehler."

i18n.map "de", de
13 changes: 8 additions & 5 deletions client/i18n/spanish.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ es =
minChar: "7 carácteres minimo."
pwOneLetter: "Minimo una letra."
pwOneDigit: "Minimo un dígito."
uernameRequired: "Usuario es necesario"
emailRequired: "Email es necesario"
signupCodeRequired: "Código para suscribir es necesario"
signupCodeIncorrect: "Código para suscribir no coincide"
unknown: "Error desconocido"
usernameRequired: "Usuario es necesario."
emailRequired: "Email es necesario."
signupCodeRequired: "Código para suscribir es necesario."
signupCodeIncorrect: "Código para suscribir no coincide."
userValidationFailed: "[SP] User validation failed."
emailAlreadyExists: "[SP] Email already exists."
usernameAlreadyExists: "[SP] Username already exists."
unknown: "Error desconocido."

i18n.map "es", es
30 changes: 23 additions & 7 deletions client/views/signUp/signUp.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
signUpErrorMap = {
'User validation failed': 'error.userValidationFailed',
'Email already exists.': 'error.emailAlreadyExists',
'Username already exists.': 'error.usernameAlreadyExists'
}

Template.entrySignUp.helpers
showEmail: ->
fields = AccountsEntry.settings.passwordSignupFields
Expand Down Expand Up @@ -97,7 +103,7 @@ Template.entrySignUp.events
'USERNAME_ONLY'], fields)

if usernameRequired && username.length is 0
Session.set('entryError', i18n("error.uernameRequired"))
Session.set('entryError', i18n("error.usernameRequired"))
return

if emailRequired && email.length is 0
Expand All @@ -118,20 +124,30 @@ Template.entrySignUp.events
password: password
profile: AccountsEntry.settings.defaultProfile || {}
if username
data.username = username
newUserData.username = username
Accounts.createUser newUserData, (err, data) ->
if err
Session.set('entryError', err.reason)
errorMsg = signUpErrorMap[err.reason]
errorMsg = 'error.unknown' if errorMsg is undefined
Session.set('entryError', i18n(errorMsg))
return
#login on client
if _.contains([
'USERNAME_AND_EMAIL',
'EMAIL_ONLY'], AccountsEntry.settings.passwordSignupFields)
Meteor.loginWithPassword(email, password)
Meteor.loginWithPassword(email, password, (error) ->
if error
Session.set('entryError', i18n("error.unknown"))
else
Router.go AccountsEntry.settings.dashboardRoute
)
else
Meteor.loginWithPassword(username, password)

Router.go AccountsEntry.settings.dashboardRoute
Meteor.loginWithPassword(username, password, (error) ->
if error
Session.set('entryError', i18n("error.unknown"))
else
Router.go AccountsEntry.settings.dashboardRoute
)
else
Session.set('entryError', i18n("error.signupCodeIncorrect"))
return
Expand Down