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

store username with new user #86

Merged
merged 7 commits into from
Feb 17, 2014
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 10 additions & 0 deletions client/entry.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ AccountsEntry =
router.stop()

@AccountsEntry = AccountsEntry


class @T9NHelper

@translate: (code) ->
# console.log "translate: #{code}"
T9n.get code, "error.accounts"

@accountsError: (err) ->
Session.set 'entryError', @translate err.reason
6 changes: 1 addition & 5 deletions client/i18n/english.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,5 @@ en =
signupCodeRequired: "Signup code is required."
signupCodeIncorrect: "Signup code is incorrect."
signInRequired: "You must be signed in to do that."
userValidationFailed: "User validation failed."
emailAlreadyExists: "Email already exists."
usernameAlreadyExists: "Username already exists."
unknown: "Unknown error."

i18n.map "en", en
T9n.map "en", en
8 changes: 2 additions & 6 deletions client/i18n/german.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ de =
emailRequired: "E-Mail benötigt."
signupCodeRequired: "Registrierungscode benötigt."
signupCodeIncorrect: "Registrierungscode ungültig."
signInRequired: "Sie müssen das tun unterzeichnet werden."
userValidationFailed: "[DE] User validation failed."
emailAlreadyExists: "[DE] Email already exists."
usernameAlreadyExists: "[DE] Username already exists."
unknown: "Unbekannter Fehler."
signInRequired: "Sie müssen sich anmelden."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you actually speak German? I've just been using Google Translate to fill these in so far, I figured it would botch pretty bad and I feel like my gut was right in the this case :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


i18n.map "de", de
T9n.map "de", de
6 changes: 1 addition & 5 deletions client/i18n/spanish.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ es =
signupCodeRequired: "Código para suscribir es necesario."
signupCodeIncorrect: "Código para suscribir no coincide."
signInRequired: "Debes iniciar sesión para hacer eso."
userValidationFailed: "[SP] User validation failed."
emailAlreadyExists: "[SP] Email already exists."
usernameAlreadyExists: "[SP] Username already exists."
unknown: "Error desconocido."

i18n.map "es", es
T9n.map "es", es
2 changes: 1 addition & 1 deletion client/views/signIn/signIn.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Template.entrySignIn.events
Meteor.loginWithPassword(Session.get('email'), Session.get('password'), (error)->
Session.set('password', undefined)
if error
Session.set('entryError', error.reason)
T9NHelper.accountsError err
else
Router.go AccountsEntry.settings.dashboardRoute
)
18 changes: 4 additions & 14 deletions client/views/signUp/signUp.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
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 @@ -120,31 +114,27 @@ Template.entrySignUp.events
console.log err
if valid
newUserData =
username: username
email: email
password: password
profile: AccountsEntry.settings.defaultProfile || {}
if username
newUserData.username = username
Accounts.createUser newUserData, (err, data) ->
if err
errorMsg = signUpErrorMap[err.reason]
errorMsg = 'error.unknown' if errorMsg is undefined
Session.set('entryError', i18n(errorMsg))
T9NHelper.accountsError err
return
#login on client
if _.contains([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we nuking setting the profile here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though I deleted this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we don't want this line removed... Are you removing it on purpose for some reason?

'USERNAME_AND_EMAIL',
'EMAIL_ONLY'], AccountsEntry.settings.passwordSignupFields)
Meteor.loginWithPassword(email, password, (error) ->
if error
Session.set('entryError', i18n("error.unknown"))
T9NHelper.accountsError err
else
Router.go AccountsEntry.settings.dashboardRoute
)
else
Meteor.loginWithPassword(username, password, (error) ->
if error
Session.set('entryError', i18n("error.unknown"))
T9NHelper.accountsError err
else
Router.go AccountsEntry.settings.dashboardRoute
)
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Package.on_use(function(api) {
api.imply('accounts-base', ['client', 'server']);
api.export('AccountsEntry', ['client', 'server']);
api.use('iron-router', ['client', 'server']);
api.use('just-i18n', ['client']);
api.use(['just-i18n', 'accounts-t9n'], ['client']);
api.add_files(['shared/router.coffee'], ['client', 'server']);

});
3 changes: 2 additions & 1 deletion smart.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"git": "https://github.com/BeDifferential/accounts-entry.git",
"packages": {
"iron-router": "0.6.2",
"just-i18n": {}
"just-i18n": {},
"accounts-t9n": {}
}
}