Skip to content

Commit 79c686c

Browse files
committed
Preserving values if user encounter an error in account creation
This solves #1204
1 parent 5729fe5 commit 79c686c

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

default-views/account/register-form.hbs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="form-group">
99
<label class="control-label" for="username">Username*</label>
1010
<input type="text" class="form-control" name="username" id="username" placeholder="alice"
11-
required/>
11+
required value="{{username}}"/>
1212

1313
{{#if multiuser}}
1414
<p>Your username should be a lower-case word with only
@@ -54,18 +54,18 @@
5454

5555
<div class="form-group">
5656
<label class="control-label" for="name">Name*</label>
57-
<input type="text" class="form-control" name="name" id="name" required/>
57+
<input type="text" class="form-control" name="name" id="name" required value="{{name}}"/>
5858
</div>
5959

6060
<div class="form-group">
6161
<label class="control-label" for="email">Email*</label>
62-
<input type="email" class="form-control" name="email" id="email"/>
62+
<input type="email" class="form-control" name="email" id="email" value="{{email}}"/>
6363
<span class="help-block">Your email will only be used for account recovery</span>
6464
</div>
6565

6666
<div class="form-group">
6767
<label class="control-label" for="externalWebId">External WebID:</label>
68-
<input type="text" class="form-control" name="externalWebId" id="externalWebId"/>
68+
<input type="text" class="form-control" name="externalWebId" id="externalWebId" value="{{externalWebId}}"/>
6969
<span class="help-block">
7070
We will generate a Web ID when you register, but if you already have a Web ID hosted elsewhere that you'd prefer to use to log in, enter it here
7171
</span>
@@ -75,7 +75,7 @@
7575
{{#if tocUri}}
7676
<div class="checkbox">
7777
<label>
78-
<input type="checkbox" name="acceptToc" value="true">
78+
<input type="checkbox" name="acceptToc" value="true" {{acceptToc ? "checked" : ""}}>
7979
I agree to the <a href="{{tocUri}}" target="_blank">Terms &amp; Conditions</a> of this service
8080
</label>
8181
</div>

lib/requests/auth-request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ class AuthRequest {
150150
*
151151
* @param error {Error}
152152
*/
153-
error (error) {
153+
error (error, body) {
154154
error.statusCode = error.statusCode || 400
155155

156-
this.renderForm(error)
156+
this.renderForm(error, body)
157157
}
158158

159159
/**

lib/requests/create-account-request.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class CreateAccountRequest extends AuthRequest {
9191
request.validate()
9292
await request.createAccount()
9393
} catch (error) {
94-
request.error(error)
94+
request.error(error, req.body)
9595
}
9696
}
9797

@@ -106,7 +106,7 @@ class CreateAccountRequest extends AuthRequest {
106106
/**
107107
* Renders the Register form
108108
*/
109-
renderForm (error) {
109+
renderForm (error, data = {}) {
110110
let authMethod = this.accountManager.authMethod
111111

112112
let params = Object.assign({}, this.authQueryParams, {
@@ -116,7 +116,12 @@ class CreateAccountRequest extends AuthRequest {
116116
registerDisabled: authMethod === 'tls',
117117
returnToUrl: this.returnToUrl,
118118
tocUri: this.tocUri,
119-
disablePasswordChecks: this.disablePasswordChecks
119+
disablePasswordChecks: this.disablePasswordChecks,
120+
username: data.username,
121+
name: data.name,
122+
email: data.email,
123+
externalWebId: data.externalWebId,
124+
acceptToc: data.acceptToc
120125
})
121126

122127
if (error) {

0 commit comments

Comments
 (0)