Skip to content

Commit c17b195

Browse files
authored
Improve explanations of usernames (#864)
* Reintroduce instructions * Writing into URIs work * Communicate multiuser * Downcase the username * Fix bugs in downcasing * Fix YA bug in downcasing * Write the hostname into the page too
1 parent ec5821f commit c17b195

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

default-views/account/register-form.hbs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,30 @@
99
<label class="control-label" for="username">Username*</label>
1010
<input type="text" class="form-control" name="username" id="username" placeholder="alice"
1111
required/>
12-
</div>
12+
13+
{{#if multiuser}}
14+
<p>Your username should be a lower-case word with only
15+
letters a-z and numbers 0-9 and without periods.</p>
16+
<p>Your public Solid POD URL will be:
17+
<tt>https://<span class="editable-username">alice</span>.<script type="text/javascript">
18+
document.write(window.location.host)
19+
</script></tt></p>
20+
<p>Your public Solid WebID will be:
21+
<tt>https://<span class="editable-username">alice</span>.<script type="text/javascript">
22+
document.write(window.location.host)
23+
</script>/profile/card#me</tt></p>
24+
25+
<p>Your <em>POD URL</em> is like the homepage for your Solid
26+
pod. By default, it is readable by the public, but you can
27+
always change that if you like by changing the access
28+
control.</p>
29+
30+
<p>Your <em>Solid WebID</em> is your globally unique name
31+
that you can use to identify and authenticate yourself with
32+
other PODs across the world.</p>
33+
{{/if}}
34+
35+
</div>
1336

1437
<div class="form-group has-feedback">
1538
<label class="control-label" for="password">Password*</label>
@@ -76,3 +99,14 @@
7699
<script src="/common/js/owasp-password-strength-test.js" defer></script>
77100
<script src="/common/js/text-encoder-lite.min.js" defer></script>
78101
<script src="/common/js/solid.js" defer></script>
102+
103+
<script>
104+
var username = document.getElementById('username');
105+
username.onkeyup = function() {
106+
var list = document.getElementsByClassName('editable-username');
107+
for (let item of list) {
108+
item.innerHTML = username.value.toLowerCase()
109+
}
110+
}
111+
</script>
112+

lib/models/account-manager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ class AccountManager {
350350
webId: userData.webid || userData.webId || userData.externalWebId
351351
}
352352

353+
if (userConfig.username) {
354+
userConfig.username = userConfig.username.toLowerCase()
355+
}
356+
353357
try {
354358
userConfig.webId = userConfig.webId || this.accountWebIdFor(userConfig.username)
355359
} catch (err) {

lib/requests/create-account-request.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ class CreateAccountRequest extends AuthRequest {
5656

5757
let body = req.body || {}
5858

59-
options.username = body.username
60-
61-
if (options.username) {
59+
if (body.username) {
60+
options.username = body.username.toLowerCase()
6261
options.userAccount = accountManager.userAccountFrom(body)
6362
}
6463

@@ -101,7 +100,8 @@ class CreateAccountRequest extends AuthRequest {
101100
{
102101
returnToUrl: this.returnToUrl,
103102
loginUrl: this.loginUrl(),
104-
registerDisabled: authMethod === 'tls'
103+
registerDisabled: authMethod === 'tls',
104+
multiuser: this.accountManager.multiuser
105105
})
106106

107107
if (error) {
@@ -200,6 +200,7 @@ class CreateAccountRequest extends AuthRequest {
200200
*/
201201
cancelIfUsernameInvalid (userAccount) {
202202
if (!userAccount.username || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(userAccount.username)) {
203+
debug('Invalid username ' + userAccount.username)
203204
const error = new Error('Invalid username')
204205
error.status = 400
205206
throw error

0 commit comments

Comments
 (0)