diff --git a/.versions b/.versions new file mode 100644 index 00000000..dd355fb5 --- /dev/null +++ b/.versions @@ -0,0 +1,65 @@ +accounts-base@1.2.0 +accounts-password@1.1.1 +base64@1.0.3 +binary-heap@1.0.3 +blaze@2.1.2 +blaze-tools@1.0.3 +boilerplate-generator@1.0.3 +callback-hook@1.0.3 +check@1.0.5 +coffeescript@1.0.6 +ddp@1.1.0 +deps@1.0.7 +ejson@1.0.6 +email@1.0.6 +geojson-utils@1.0.3 +handlebars@1.0.3 +html-tools@1.0.4 +htmljs@1.0.4 +id-map@1.0.3 +iron:controller@1.0.8 +iron:core@1.0.8 +iron:dynamic-template@1.0.8 +iron:layout@1.0.8 +iron:location@1.0.9 +iron:middleware-stack@1.0.9 +iron:router@1.0.9 +iron:url@1.0.9 +joshowens:simple-form@0.2.2 +jquery@1.11.3_2 +json@1.0.3 +less@1.0.14 +local-test:vilango:accounts-entry@1.0.3-5 +localstorage@1.0.3 +logging@1.0.7 +meteor@1.1.6 +minifiers@1.1.5 +minimongo@1.0.8 +mongo@1.1.0 +mongo-livedata@1.0.8 +mrt:underscore-string-latest@2.3.3 +npm-bcrypt@0.7.8_2 +observe-sequence@1.0.6 +ordered-dict@1.0.3 +random@1.0.3 +reactive-dict@1.1.0 +reactive-var@1.0.5 +retry@1.0.3 +routepolicy@1.0.5 +schnie:uploader@2.0.3 +service-configuration@1.0.4 +session@1.1.0 +sha@1.0.3 +softwarerero:accounts-t9n@1.1.1 +spacebars@1.0.6 +spacebars-compiler@1.0.6 +srp@1.0.3 +templating@1.1.1 +test-helpers@1.0.4 +tinytest@1.0.5 +tracker@1.0.7 +ui@1.0.6 +underscore@1.0.3 +vilango:accounts-entry@1.0.3-5 +webapp@1.2.0 +webapp-hashing@1.0.3 diff --git a/README.md b/README.md index 79c1fa16..4fbacd4f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ layout: default username: Differential repo: accounts-entry desc: Meteor sign up and sign in pages. -version: 0.9.0 +version: 1.0.3-2 --- diff --git a/client/entry.coffee b/client/entry.coffee index 8166c336..4c7fb47d 100644 --- a/client/entry.coffee +++ b/client/entry.coffee @@ -10,6 +10,10 @@ AccountsEntry = extraSignUpFields: [] showOtherLoginServices: true + hooks: + afterSignUpHook: (newUserId)-> + console.log "afterSignUp hook", newUserId + isStringEmail: (email) -> emailPattern = /^([\w.-]+)@([\w.-]+)\.([a-zA-Z.]{2,6})$/i if email.match emailPattern then true else false @@ -29,11 +33,12 @@ AccountsEntry = extraCondition ?= true unless Meteor.loggingIn() if Meteor.user() and extraCondition - router.next() + #router.next() else Session.set('fromWhere', router.url) Router.go('/sign-in') Session.set('entryError', t9n('error.signInRequired')) + #router.next() @AccountsEntry = AccountsEntry diff --git a/client/helpers.coffee b/client/helpers.coffee index fb084259..8d9f594a 100644 --- a/client/helpers.coffee +++ b/client/helpers.coffee @@ -38,3 +38,13 @@ UI.registerHelper 'passwordLoginService', -> UI.registerHelper 'showCreateAccountLink', -> return !Accounts._options.forbidClientAccountCreation + + +class @Helper + @disableBtns = ($btns) -> + $btns.html($btns.html()+' ') + $btns.attr("disabled", "disabled") + + @enableBtns = ($btns) -> + $btns.html(_.strLeft($btns.html(),' ')) + $btns.attr("disabled", null) \ No newline at end of file diff --git a/client/views/forgotPassword/forgotPassword.coffee b/client/views/forgotPassword/forgotPassword.coffee index 4f388207..c9f9305d 100644 --- a/client/views/forgotPassword/forgotPassword.coffee +++ b/client/views/forgotPassword/forgotPassword.coffee @@ -7,10 +7,21 @@ Template.entryForgotPassword.helpers Template.entryForgotPassword.events 'submit #forgotPassword': (event) -> event.preventDefault() - Session.set('email', $('input[name="forgottenEmail"]').val()) + Session.set('entryError', null) + + email = $('input[name="forgottenEmail"]').val() + if (AccountsEntry.isStringEmail(email) and AccountsEntry.settings.emailToLower) or + (not AccountsEntry.isStringEmail(email) and AccountsEntry.settings.usernameToLower) + email = email.toLowerCase() + + Session.set('email', email) + $btns = $(event.target).find("button[type='submit']") + Helper.disableBtns($btns) if Session.get('email').length is 0 Session.set('entryError', 'Email is required') + + Helper.enableBtns($btns) return Accounts.forgotPassword({ @@ -19,5 +30,7 @@ Template.entryForgotPassword.events if error Session.set('entryError', error.reason) else - Router.go AccountsEntry.settings.homeRoute + Router.go AccountsEntry.settings.resetPasswordSuccessRoute + + Helper.enableBtns($btns) ) diff --git a/client/views/resetPassword/resetPassword.coffee b/client/views/resetPassword/resetPassword.coffee index d957dfd2..9307f4df 100644 --- a/client/views/resetPassword/resetPassword.coffee +++ b/client/views/resetPassword/resetPassword.coffee @@ -8,6 +8,9 @@ Template.entryResetPassword.events 'submit #resetPassword': (event) -> event.preventDefault() + $btns = $(event.target).find("button[type='submit']") + Helper.disableBtns($btns) + password = $('input[type="password"]').val() passwordErrors = do (password)-> @@ -30,7 +33,9 @@ Template.entryResetPassword.events return false - if passwordErrors then return + if passwordErrors + Helper.enableBtns($btns) + return Accounts.resetPassword Session.get('resetToken'), password, (error) -> if error @@ -38,3 +43,5 @@ Template.entryResetPassword.events else Session.set('resetToken', null) Router.go AccountsEntry.settings.dashboardRoute + + Helper.enableBtns($btns) \ No newline at end of file diff --git a/client/views/signIn/signIn.coffee b/client/views/signIn/signIn.coffee index 96bfb682..2902a7cf 100644 --- a/client/views/signIn/signIn.coffee +++ b/client/views/signIn/signIn.coffee @@ -30,6 +30,9 @@ AccountsEntry.entrySignInEvents = { 'submit #signIn': (event) -> event.preventDefault() + $btns = $(event.target).find("button[type='submit']") + Helper.disableBtns($btns) + email = $('input[name="email"]').val() if (AccountsEntry.isStringEmail(email) and AccountsEntry.settings.emailToLower) or (not AccountsEntry.isStringEmail(email) and AccountsEntry.settings.usernameToLower) @@ -47,6 +50,8 @@ AccountsEntry.entrySignInEvents = { Session.set('fromWhere', undefined) else Router.go AccountsEntry.settings.dashboardRoute + + Helper.enableBtns($btns) ) } diff --git a/client/views/signUp/extraSignUpFields.coffee b/client/views/signUp/extraSignUpFields.coffee index 1b240d03..808aed75 100644 --- a/client/views/signUp/extraSignUpFields.coffee +++ b/client/views/signUp/extraSignUpFields.coffee @@ -4,7 +4,25 @@ Template.entryExtraSignUpFields.helpers Template._entryExtraSignUpField.helpers isTextField: -> - @type isnt "check_box" + @type isnt "check_box" and @type isnt "select_box" isCheckbox: -> @type is "check_box" + + isSelectbox: -> + @type is "select_box" + + + +# Added by GB +Template.entryExtraSignUpFields.events + 'change select.languageCode': (evt) -> + newLang = $(evt.target).val(); + console.log "Template.entryExtraSignUpFields.events","change languageCode", newLang + i18n.setLanguage(newLang) + +Template.entryExtraSignUpFields.rendered = -> + $select = $("select.languageCode") + if $select + $("select.languageCode").val(i18n.getLanguage()) + \ No newline at end of file diff --git a/client/views/signUp/extraSignUpFields.html b/client/views/signUp/extraSignUpFields.html index fdd5275a..223d4cf1 100644 --- a/client/views/signUp/extraSignUpFields.html +++ b/client/views/signUp/extraSignUpFields.html @@ -16,4 +16,10 @@ {{check_box name label=label required=required}} {{/if}} + + {{#if isSelectbox}} +
+ {{select_box field class=field optionValues=optionValues type=type label=label required=required}} +
+ {{/if}} diff --git a/client/views/signUp/signUp.coffee b/client/views/signUp/signUp.coffee index 8eb32bc8..9ca1eef8 100644 --- a/client/views/signUp/signUp.coffee +++ b/client/views/signUp/signUp.coffee @@ -52,6 +52,10 @@ AccountsEntry.entrySignUpEvents = { 'submit #signUp': (event, t) -> event.preventDefault() + $btns = $(event.target).find("button[type='submit']") + Helper.disableBtns($btns) + + username = if t.find('input[name="username"]') t.find('input[name="username"]').value.toLowerCase() @@ -103,7 +107,9 @@ AccountsEntry.entrySignUpEvents = { return false - if passwordErrors then return + if passwordErrors + Helper.enableBtns($btns) + return emailRequired = _.contains([ 'USERNAME_AND_EMAIL', @@ -115,18 +121,22 @@ AccountsEntry.entrySignUpEvents = { if usernameRequired && username.length is 0 Session.set('entryError', t9n("error.usernameRequired")) + Helper.enableBtns($btns) return if username && AccountsEntry.isStringEmail(username) Session.set('entryError', t9n("error.usernameIsEmail")) + Helper.enableBtns($btns) return if emailRequired && email.length is 0 Session.set('entryError', t9n("error.emailRequired")) + Helper.enableBtns($btns) return if AccountsEntry.settings.showSignupCode && signupCode.length is 0 Session.set('entryError', t9n("error.signupCodeRequired")) + Helper.enableBtns($btns) return @@ -137,28 +147,37 @@ AccountsEntry.entrySignUpEvents = { email: email password: AccountsEntry.hashPassword(password) profile: filteredExtraFields - Meteor.call 'entryCreateUser', newUserData, (err, data) -> + Meteor.call 'entryCreateUser', newUserData, (err, newUserId) -> if err console.log err T9NHelper.accountsError err + Helper.enableBtns($btns) return + + AccountsEntry.hooks.afterSignUpHook(newUserId) + #login on client isEmailSignUp = _.contains([ 'USERNAME_AND_EMAIL', 'EMAIL_ONLY'], AccountsEntry.settings.passwordSignupFields) userCredential = if isEmailSignUp then email else username - Meteor.loginWithPassword userCredential, password, (error) -> - if error - console.log error - T9NHelper.accountsError error - else if Session.get 'fromWhere' - Router.go Session.get('fromWhere') - Session.set 'fromWhere', undefined - else - Router.go AccountsEntry.settings.dashboardRoute + + if AccountsEntry.settings.verifyEmail + Router.go AccountsEntry.settings.verifyEmailRoute + else + Meteor.loginWithPassword userCredential, password, (error) -> + if error + console.log error + T9NHelper.accountsError error + else if Session.get 'fromWhere' + Router.go Session.get('fromWhere') + Session.set 'fromWhere', undefined + else + Router.go AccountsEntry.settings.dashboardRoute else console.log err Session.set 'entryError', t9n("error.signupCodeIncorrect") + Helper.enableBtns($btns) return } diff --git a/client/views/signUp/signUp.html b/client/views/signUp/signUp.html index b2a693c0..1d2eeddf 100644 --- a/client/views/signUp/signUp.html +++ b/client/views/signUp/signUp.html @@ -65,8 +65,8 @@

{{t9n "createAccount"}}

{{/if}} {{#if both}}

{{t9n "clickAgree"}} - {{t9n "privacyPolicy"}} {{t9n "and"}} - {{t9n "terms"}}. + {{t9n "privacyPolicy"}} {{t9n "and"}} + {{t9n "terms"}}.

{{else}} {{#unless neither}} diff --git a/package.js b/package.js index 5b41c993..e9cf857a 100644 --- a/package.js +++ b/package.js @@ -1,14 +1,17 @@ Package.describe({ summary: "Make signin and signout their own pages with routes.", - version: '1.0.0', - name: "joshowens:accounts-entry", - githubUrl: 'https://github.com/Differential/accounts-entry', -}); + version: '1.0.3-5', + name: "vilango:accounts-entry" + }); Package.onUse(function(api) { - api.versionsFrom("METEOR@0.9.0"); + api.versionsFrom("METEOR@0.9.2"); - api.use(['iron:router@1.0.0', 'softwarerero:accounts-t9n@1.0.0', 'joshowens:simple-form@0.1.8'], ['client', 'server']); + api.use([ + 'iron:router@1.0.9', + 'softwarerero:accounts-t9n@1.1.1', + 'joshowens:simple-form@0.2.2' + ], ['client', 'server']); // CLIENT api.use([ 'deps', @@ -89,7 +92,7 @@ Package.onTest(function (api) { 'coffeescript' ]); api.use(['iron:router', 'softwarerero:accounts-t9n', 'joshowens:simple-form'], ['client', 'server']); - api.use('joshowens:accounts-entry'); + api.use('vilango:accounts-entry'); api.addFiles(['tests/route.coffee', 'tests/client.html', 'tests/client.coffee'], 'client'); }); diff --git a/server/entry.coffee b/server/entry.coffee index fd467daf..55a312cd 100644 --- a/server/entry.coffee +++ b/server/entry.coffee @@ -30,4 +30,8 @@ Meteor.startup -> password: user.password profile: _.extend(profile, user.profile) if (user.email && Accounts._options.sendVerificationEmail) + @unblock() Accounts.sendVerificationEmail(userId, user.email) + + return userId + diff --git a/shared/router.coffee b/shared/router.coffee index 7af171b8..c02bca71 100644 --- a/shared/router.coffee +++ b/shared/router.coffee @@ -69,8 +69,11 @@ Router.map -> path: '/sign-out' onBeforeAction: ()-> Session.set('entryError', undefined) - if AccountsEntry.settings.homeRoute - Meteor.logout () -> + Meteor.logout (error) -> + if error + console.error "logout failed", error + @next() + else Router.go AccountsEntry.settings.homeRoute @route 'entryResetPassword', @@ -87,5 +90,6 @@ _.each Router.routes, (route)-> # Change the fromWhere session variable when you leave a path Router.onStop -> # If the route is an entry route, no need to save it - if (!_.contains(exclusions, Router.current().route.name)) - Session.set('fromWhere', Router.current().path) + if Meteor.isClient + if (!_.contains(exclusions, Router.current()?.route?.name)) + Session.set('fromWhere', Router.current().path) \ No newline at end of file diff --git a/versions.json b/versions.json deleted file mode 100644 index c659dff6..00000000 --- a/versions.json +++ /dev/null @@ -1,251 +0,0 @@ -{ - "dependencies": [ - [ - "accounts-base", - "1.1.2" - ], - [ - "accounts-password", - "1.0.4" - ], - [ - "application-configuration", - "1.0.3" - ], - [ - "base64", - "1.0.1" - ], - [ - "binary-heap", - "1.0.1" - ], - [ - "blaze", - "2.0.3" - ], - [ - "blaze-tools", - "1.0.1" - ], - [ - "boilerplate-generator", - "1.0.1" - ], - [ - "callback-hook", - "1.0.1" - ], - [ - "check", - "1.0.2" - ], - [ - "coffeescript", - "1.0.4" - ], - [ - "ddp", - "1.0.11" - ], - [ - "deps", - "1.0.5" - ], - [ - "ejson", - "1.0.4" - ], - [ - "email", - "1.0.4" - ], - [ - "follower-livedata", - "1.0.2" - ], - [ - "geojson-utils", - "1.0.1" - ], - [ - "handlebars", - "1.0.1" - ], - [ - "html-tools", - "1.0.2" - ], - [ - "htmljs", - "1.0.2" - ], - [ - "id-map", - "1.0.1" - ], - [ - "iron:controller", - "1.0.0" - ], - [ - "iron:core", - "1.0.0" - ], - [ - "iron:dynamic-template", - "1.0.0" - ], - [ - "iron:layout", - "1.0.0" - ], - [ - "iron:location", - "1.0.0" - ], - [ - "iron:middleware-stack", - "1.0.0" - ], - [ - "iron:router", - "1.0.0" - ], - [ - "iron:url", - "1.0.0" - ], - [ - "joshowens:simple-form", - "0.1.8" - ], - [ - "jquery", - "1.0.1" - ], - [ - "json", - "1.0.1" - ], - [ - "less", - "1.0.11" - ], - [ - "localstorage", - "1.0.1" - ], - [ - "logging", - "1.0.5" - ], - [ - "meteor", - "1.1.3" - ], - [ - "minifiers", - "1.1.2" - ], - [ - "minimongo", - "1.0.5" - ], - [ - "mongo", - "1.0.8" - ], - [ - "mrt:underscore-string-latest", - "2.3.3" - ], - [ - "npm-bcrypt", - "0.7.7" - ], - [ - "observe-sequence", - "1.0.3" - ], - [ - "ordered-dict", - "1.0.1" - ], - [ - "random", - "1.0.1" - ], - [ - "reactive-dict", - "1.0.4" - ], - [ - "reactive-var", - "1.0.3" - ], - [ - "retry", - "1.0.1" - ], - [ - "routepolicy", - "1.0.2" - ], - [ - "service-configuration", - "1.0.2" - ], - [ - "session", - "1.0.4" - ], - [ - "sha", - "1.0.1" - ], - [ - "softwarerero:accounts-t9n", - "1.0.0" - ], - [ - "spacebars", - "1.0.3" - ], - [ - "spacebars-compiler", - "1.0.3" - ], - [ - "srp", - "1.0.1" - ], - [ - "templating", - "1.0.9" - ], - [ - "tracker", - "1.0.3" - ], - [ - "ui", - "1.0.4" - ], - [ - "underscore", - "1.0.1" - ], - [ - "webapp", - "1.1.4" - ], - [ - "webapp-hashing", - "1.0.1" - ] - ], - "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.35", - "format": "1.0" -} \ No newline at end of file