Skip to content

Commit

Permalink
Add extra signup field support. [Fixes #179]
Browse files Browse the repository at this point in the history
  • Loading branch information
queso committed Jun 4, 2014
1 parent be97ac8 commit ea0667e
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/entry.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AccountsEntry =
emailToLower: true
usernameToLower: false
entrySignUp: '/sign-up'
extraSignUpFields: []

isStringEmail: (email) ->
emailPattern = /^([\w.-]+)@([\w.-]+)\.([a-zA-Z.]{2,6})$/i
Expand Down
3 changes: 3 additions & 0 deletions client/views/signUp/extraSignUpFields.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Template.entryExtraSignUpFields.helpers
extraSignUpFields: ->
AccountsEntry.settings.extraSignUpFields
7 changes: 7 additions & 0 deletions client/views/signUp/extrasignUpFields.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template name="entryExtraSignUpFields">
{{#each extraSignUpFields}}
<div class="form_group">
{{text_field name type=type required=required}}
</div>
{{/each}}
</template>
1 change: 1 addition & 0 deletions client/views/signUp/signUp.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ <h3>{{t9n "createAccount"}}</h3>
</div>
{{/if}}

{{> entryExtraSignUpFields}}
<button type="submit" class="submit btn btn-block btn-default">{{t9n "signUp"}}</button>
</form>
{{/if}}
Expand Down
5 changes: 5 additions & 0 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Package.on_use(function(api) {
'handlebars',
'session',
'coffeescript',
'simple-form',

This comment has been minimized.

Copy link
@timbrandin

timbrandin Aug 29, 2014

Contributor

It seems like we're depending on a unmigrated version of simple-form over here for 0.9.x

'less']
, 'client');

Expand All @@ -26,6 +27,8 @@ Package.on_use(function(api) {
'client/views/signIn/signIn.coffee',
'client/views/signUp/signUp.html',
'client/views/signUp/signUp.coffee',
'client/views/signUp/extraSignUpFields.html',
'client/views/signUp/extraSignUpFields.coffee',
'client/views/forgotPassword/forgotPassword.html',
'client/views/forgotPassword/forgotPassword.coffee',
'client/views/resetPassword/resetPassword.html',
Expand Down Expand Up @@ -70,11 +73,13 @@ Package.on_use(function(api) {

Package.on_test(function (api) {
api.use(['tinytest',
'underscore',
'handlebars',
'test-helpers',
'templating',
'mongo-livedata',
'coffeescript',
'simple-form',
'iron-router']);
api.use('accounts-entry');

Expand Down
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/Differential/accounts-entry.git",
"packages": {
"iron-router": "0.7.0",
"accounts-t9n": "0.0.5"
"accounts-t9n": "0.0.5",
"simple-form": "0.1.4"
}
}
9 changes: 8 additions & 1 deletion tests/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@ Tinytest.add "Accounts Entry - forgot password link should not show up if userna
div = renderToDiv(Template.test_helper_sign_in)
html = canonicalizeHtml(div.innerHTML)
scan = html.indexOf('<a href="/forgot-password">')
test.equal(scan, -1, "Forgot password link should not show up if username only is set")
test.equal(scan, -1, "Forgot password link should not show up if username only is set")

Tinytest.add "Accounts Entry - adding extra fields to the layout", (test) ->
AccountsEntry.settings.extraSignUpFields = [{name: 'zipcode', required: true, type: 'number'}]
Package['accounts-password'] = true
div = renderToDiv(Template.test_helper_sign_up)
html = canonicalizeHtml(div.innerHTML)
test.include html, '<div class="form_group"><label for="zipcode">Zipcode</label><input class="form-control" id="zipcode" name="zipcode" required="" type="number" value=""></div>'
6 changes: 5 additions & 1 deletion tests/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@

<template name="test_helper_sign_in">
{{> entrySignIn}}
</template>
</template>

<template name="test_helper_sign_up">
{{> entrySignUp}}
</template>

0 comments on commit ea0667e

Please sign in to comment.