Skip to content

Commit 0555e66

Browse files
authored
Merge pull request #1277 from solid/dev
dev branch
2 parents 5729fe5 + d828545 commit 0555e66

File tree

12 files changed

+647
-469
lines changed

12 files changed

+647
-469
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v8.16.0

common/js/auth-buttons.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
await auth.logout()
3131
}
3232
// Now that we have a cookie, reload to display the authenticated page
33-
location.reload()
33+
const webId = new URL(session.webId)
34+
const podUrl = `${webId.protocol}//${webId.host}`
35+
location.href = podUrl
3436
}
3537
}
3638

@@ -43,7 +45,6 @@
4345
// Redirect to the registration page
4446
function register () {
4547
const registration = new URL('/register', location)
46-
registration.searchParams.set('returnToUrl', location)
4748
location.href = registration
4849
}
4950
})(solid)

default-templates/new-account/index.html

Lines changed: 0 additions & 77 deletions
This file was deleted.

default-views/account/register-form.hbs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<div class="col-md-6">
33
<div class="panel panel-default">
44
<div class="panel-body">
5-
<form method="post" action="/api/accounts/new">
5+
<form method="post" action="/api/accounts/new" id="RegisterForm">
66
{{> shared/error}}
77

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,28 +54,35 @@
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

66-
<div class="form-group">
66+
<div class="checkbox">
67+
<label>
68+
<input type="checkbox" name="connectExternalWebId" value="true" id="ConnectExternalWebId" {{#if connectExternalWebId}}checked{{/if}}/>
69+
Connect to External WebID (<strong>Advanced feature</strong>)
70+
</label>
71+
</div>
72+
73+
<div class="form-group hidden" id="ExternalWebId">
6774
<label class="control-label" for="externalWebId">External WebID:</label>
68-
<input type="text" class="form-control" name="externalWebId" id="externalWebId"/>
75+
<input type="text" class="form-control" name="externalWebId" id="externalWebId" value="{{externalWebId}}"/>
6976
<span class="help-block">
70-
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
77+
By connecting this account with an existing webId, you can use that webId to authenticate with the new account.
7178
</span>
7279
</div>
7380

7481
{{#if enforceToc}}
7582
{{#if tocUri}}
7683
<div class="checkbox">
7784
<label>
78-
<input type="checkbox" name="acceptToc" value="true">
85+
<input type="checkbox" name="acceptToc" value="true" {{#if acceptToc}}checked{{/if}}>
7986
I agree to the <a href="{{tocUri}}" target="_blank">Terms &amp; Conditions</a> of this service
8087
</label>
8188
</div>
@@ -114,10 +121,27 @@
114121
<script>
115122
var username = document.getElementById('username');
116123
username.onkeyup = function() {
117-
var list = document.getElementsByClassName('editable-username');
118-
for (let item of list) {
119-
item.innerHTML = username.value.toLowerCase()
124+
var list = document.getElementsByClassName('editable-username');
125+
for (let item of list) {
126+
item.innerHTML = username.value.toLowerCase()
127+
}
120128
}
121-
}
129+
130+
window.addEventListener('DOMContentLoaded', function () {
131+
var connect = document.getElementById('ConnectExternalWebId')
132+
var container = document.getElementById('ExternalWebId')
133+
container.classList.toggle('hidden', !connect.checked)
134+
connect.addEventListener('change', function () {
135+
container.classList.toggle('hidden', !connect.checked)
136+
})
137+
138+
var form = document.getElementById('RegisterForm')
139+
var externalWebIdField = document.getElementById('externalWebId')
140+
form.addEventListener('submit', function () {
141+
if (!connect.checked) {
142+
externalWebIdField.value = ''
143+
}
144+
})
145+
})
122146
</script>
123147

lib/create-app.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ function createApp (argv = {}) {
6767

6868
// Serve the public 'common' directory (for shared CSS files, etc)
6969
app.use('/common', express.static(path.join(__dirname, '../common')))
70-
routeResolvedFile(app, '/common/js/', 'mashlib/dist/mashlib.js')
71-
routeResolvedFile(app, '/common/js/', 'mashlib/dist/mashlib.min.js')
72-
routeResolvedFile(app, '/common/js/', 'mashlib/dist/mashlib.min.js.map')
70+
app.use('/', express.static(path.join(__dirname, '../node_modules/mashlib/dist'), { index: false }))
7371
routeResolvedFile(app, '/common/js/', 'solid-auth-client/dist-lib/solid-auth-client.bundle.js')
7472
routeResolvedFile(app, '/common/js/', 'solid-auth-client/dist-lib/solid-auth-client.bundle.js.map')
7573
app.use('/.well-known', express.static(path.join(__dirname, '../common/well-known')))

lib/handlers/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async function handler (req, res, next) {
8989

9090
if (useDataBrowser) {
9191
res.set('Content-Type', 'text/html')
92-
const defaultDataBrowser = _path.join(__dirname, '../../static/databrowser.html')
92+
const defaultDataBrowser = _path.join(__dirname, '../../node_modules/mashlib/dist/index.html')
9393
const dataBrowserPath = ldp.dataBrowserPath === 'default' ? defaultDataBrowser : ldp.dataBrowserPath
9494
debug(' sending data browser file: ' + dataBrowserPath)
9595
res.sendFile(dataBrowserPath)

lib/models/user-account.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ class UserAccount {
7676
return parsed.protocol + '//' + parsed.host
7777
}
7878

79+
/**
80+
* Returns the Uri to the account's Pod
81+
*
82+
* @return {string}
83+
*/
84+
get podUri () {
85+
const webIdUrl = url.parse(this.webId)
86+
const podUrl = `${webIdUrl.protocol}//${webIdUrl.host}`
87+
return url.format(podUrl)
88+
}
89+
7990
/**
8091
* Returns the URI of the WebID Profile for this account.
8192
* Usage:

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: 17 additions & 4 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,13 @@ 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,
125+
connectExternalWebId: data.connectExternalWebId
120126
})
121127

122128
if (error) {
@@ -309,8 +315,15 @@ class CreateOidcAccountRequest extends CreateAccountRequest {
309315
})
310316
}
311317

318+
/**
319+
* Generate the response for the account creation
320+
*
321+
* @param userAccount {UserAccount}
322+
*
323+
* @return {UserAccount}
324+
*/
312325
sendResponse (userAccount) {
313-
let redirectUrl = this.returnToUrl || this.loginUrl()
326+
let redirectUrl = this.returnToUrl || userAccount.podUri
314327
this.response.redirect(redirectUrl)
315328

316329
return userAccount

0 commit comments

Comments
 (0)