@semapps/auth 0.4.0-alpha.24 → 0.4.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mixins/auth.sso.js +1 -1
- package/package.json +4 -4
- package/services/account.js +11 -6
package/mixins/auth.sso.js
CHANGED
@@ -40,7 +40,7 @@ const AuthSSOMixin = {
|
|
40
40
|
throw new Error('registration.not-allowed');
|
41
41
|
}
|
42
42
|
|
43
|
-
accountData = await ctx.call('auth.account.create', { uuid: profileData.uuid, email: profileData.email });
|
43
|
+
accountData = await ctx.call('auth.account.create', { uuid: profileData.uuid, email: profileData.email, username: profileData.username });
|
44
44
|
webId = await ctx.call('webid.create', this.pickWebIdData({ nick: accountData.username, ...profileData }));
|
45
45
|
newUser = true;
|
46
46
|
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@semapps/auth",
|
3
|
-
"version": "0.4.0-alpha.
|
3
|
+
"version": "0.4.0-alpha.25",
|
4
4
|
"description": "Authentification module for SemApps",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "Virtual Assembly",
|
7
7
|
"dependencies": {
|
8
|
-
"@semapps/mime-types": "0.4.0-alpha.
|
9
|
-
"@semapps/triplestore": "0.4.0-alpha.
|
8
|
+
"@semapps/mime-types": "0.4.0-alpha.25",
|
9
|
+
"@semapps/triplestore": "0.4.0-alpha.25",
|
10
10
|
"bcrypt": "^5.0.1",
|
11
11
|
"express-session": "^1.17.0",
|
12
12
|
"jsonwebtoken": "^8.5.1",
|
@@ -24,5 +24,5 @@
|
|
24
24
|
"publishConfig": {
|
25
25
|
"access": "public"
|
26
26
|
},
|
27
|
-
"gitHead": "
|
27
|
+
"gitHead": "50f9339117c5ed5e303f6d760835497890da32b1"
|
28
28
|
}
|
package/services/account.js
CHANGED
@@ -28,14 +28,17 @@ module.exports = {
|
|
28
28
|
await this.isValidUsername(ctx, username);
|
29
29
|
} else {
|
30
30
|
// If username is not provided, find an username based on the email
|
31
|
-
|
32
|
-
|
31
|
+
const usernameFromEmail = email.split('@')[0].toLowerCase();
|
32
|
+
let usernameValid = false, i = 0;
|
33
33
|
do {
|
34
|
+
username = i === 0 ? usernameFromEmail : usernameFromEmail + i;
|
35
|
+
try {
|
36
|
+
usernameValid = await this.isValidUsername(ctx, username);
|
37
|
+
} catch(e) {
|
38
|
+
// Do nothing, the loop will continue
|
39
|
+
}
|
34
40
|
i++;
|
35
|
-
|
36
|
-
if (i > 2) username += i;
|
37
|
-
usernameValid = await this.isValidUsername(ctx, username);
|
38
|
-
} while (usernameValid);
|
41
|
+
} while (!usernameValid);
|
39
42
|
}
|
40
43
|
|
41
44
|
return await this._create(ctx, {
|
@@ -149,6 +152,8 @@ module.exports = {
|
|
149
152
|
if (usernameExists) {
|
150
153
|
throw new Error('username.already.exists');
|
151
154
|
}
|
155
|
+
|
156
|
+
return true;
|
152
157
|
},
|
153
158
|
async hashPassword(password) {
|
154
159
|
return new Promise((resolve, reject) => {
|