Skip to content

Commit 6d6fe00

Browse files
committed
Added checkbox to register-form
Also added handlebar-helpers
1 parent 57cfd18 commit 6d6fe00

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

default-views/account/register-form.hbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@
7171
</span>
7272
</div>
7373

74+
{{#if (and enforceToc tocUri)}}
75+
<div class="checkbox">
76+
<label>
77+
<input type="checkbox" name="acceptToc">
78+
I agree to the <a href="{{tocUri}}" target="_blank">Terms & Conditions</a> of this service
79+
</label>
80+
</div>
81+
{{/if}}
82+
7483

7584
<button type="submit" class="btn btn-primary" id="register">Register</button>
7685

lib/create-app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = createApp
33
const express = require('express')
44
const session = require('express-session')
55
const handlebars = require('express-handlebars')
6+
const handlebarsHelpers = require('handlebars-helpers')
67
const uuid = require('uuid')
78
const cors = require('cors')
89
const LDP = require('./ldp')
@@ -163,7 +164,8 @@ function initViews (app, configPath) {
163164
app.set('views', viewsPath)
164165
app.engine('.hbs', handlebars({
165166
extname: '.hbs',
166-
partialsDir: viewsPath
167+
partialsDir: viewsPath,
168+
helpers: handlebarsHelpers()
167169
}))
168170
app.set('view engine', '.hbs')
169171
}

lib/requests/auth-request.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class AuthRequest {
2525
* @param [options.returnToUrl] {string}
2626
* @param [options.authQueryParams] {Object} Key/value hashmap of parsed query
2727
* parameters that will be passed through to the /authorize endpoint.
28+
* @param [options.enforceToc] {boolean} Whether or not to enforce the service provider's T&C
29+
* @param [options.tocUri] {string} URI to the service provider's T&C
2830
*/
2931
constructor (options) {
3032
this.response = options.response
@@ -34,6 +36,8 @@ class AuthRequest {
3436
this.returnToUrl = options.returnToUrl
3537
this.authQueryParams = options.authQueryParams || {}
3638
this.localAuth = options.localAuth
39+
this.enforceToc = options.enforceToc
40+
this.tocUri = options.tocUri
3741
}
3842

3943
/**

lib/requests/create-account-request.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class CreateAccountRequest extends AuthRequest {
2727
* @param [options.response] {HttpResponse}
2828
* @param [options.returnToUrl] {string} If present, redirect the agent to
2929
* this url on successful account creation
30+
* @param [options.enforceToc] {boolean} Whether or not to enforce the service provider's T&C
31+
* @param [options.tocUri] {string} URI to the service provider's T&C
3032
*/
3133
constructor (options) {
3234
super(options)
@@ -62,6 +64,10 @@ class CreateAccountRequest extends AuthRequest {
6264
options.userAccount = accountManager.userAccountFrom(body)
6365
}
6466

67+
const config = require('../../config')
68+
options.enforceToc = config.enforceToc
69+
options.tocUri = config.tocUri
70+
6571
switch (authMethod) {
6672
case 'oidc':
6773
options.password = body.password
@@ -97,13 +103,14 @@ class CreateAccountRequest extends AuthRequest {
97103
renderForm (error) {
98104
let authMethod = this.accountManager.authMethod
99105

100-
let params = Object.assign({}, this.authQueryParams,
101-
{
102-
returnToUrl: this.returnToUrl,
103-
loginUrl: this.loginUrl(),
104-
registerDisabled: authMethod === 'tls',
105-
multiuser: this.accountManager.multiuser
106-
})
106+
let params = Object.assign({}, this.authQueryParams, {
107+
enforceToc: this.enforceToc,
108+
loginUrl: this.loginUrl(),
109+
multiuser: this.accountManager.multiuser,
110+
registerDisabled: authMethod === 'tls',
111+
returnToUrl: this.returnToUrl,
112+
tocUri: this.tocUri
113+
})
107114

108115
if (error) {
109116
params.error = error.message

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"glob": "^7.1.1",
5757
"global-tunnel-ng": "^2.1.0",
5858
"handlebars": "^4.0.6",
59+
"handlebars-helpers": "^0.10.0",
5960
"http-proxy-middleware": "^0.18.0",
6061
"inquirer": "^1.0.2",
6162
"ip-range-check": "0.0.2",

0 commit comments

Comments
 (0)