@semapps/auth 0.4.0-alpha.23 → 0.4.0-alpha.26
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 +5 -1
- package/package.json +4 -4
- package/services/account.js +11 -5
package/mixins/auth.sso.js
CHANGED
@@ -40,7 +40,11 @@ const AuthSSOMixin = {
|
|
40
40
|
throw new Error('registration.not-allowed');
|
41
41
|
}
|
42
42
|
|
43
|
-
accountData = await ctx.call('auth.account.create', {
|
43
|
+
accountData = await ctx.call('auth.account.create', {
|
44
|
+
uuid: profileData.uuid,
|
45
|
+
email: profileData.email,
|
46
|
+
username: profileData.username
|
47
|
+
});
|
44
48
|
webId = await ctx.call('webid.create', this.pickWebIdData({ nick: accountData.username, ...profileData }));
|
45
49
|
newUser = true;
|
46
50
|
|
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.26",
|
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.26",
|
9
|
+
"@semapps/triplestore": "0.4.0-alpha.26",
|
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": "f65a5a67d02782b0539d12ed482e8cc4149e5d36"
|
28
28
|
}
|
package/services/account.js
CHANGED
@@ -28,14 +28,18 @@ 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
|
+
const usernameFromEmail = email.split('@')[0].toLowerCase();
|
31
32
|
let usernameValid = false,
|
32
|
-
i =
|
33
|
+
i = 0;
|
33
34
|
do {
|
35
|
+
username = i === 0 ? usernameFromEmail : usernameFromEmail + i;
|
36
|
+
try {
|
37
|
+
usernameValid = await this.isValidUsername(ctx, username);
|
38
|
+
} catch (e) {
|
39
|
+
// Do nothing, the loop will continue
|
40
|
+
}
|
34
41
|
i++;
|
35
|
-
|
36
|
-
if (i > 2) username += i;
|
37
|
-
usernameValid = await this.isValidUsername(ctx, username);
|
38
|
-
} while (usernameValid);
|
42
|
+
} while (!usernameValid);
|
39
43
|
}
|
40
44
|
|
41
45
|
return await this._create(ctx, {
|
@@ -149,6 +153,8 @@ module.exports = {
|
|
149
153
|
if (usernameExists) {
|
150
154
|
throw new Error('username.already.exists');
|
151
155
|
}
|
156
|
+
|
157
|
+
return true;
|
152
158
|
},
|
153
159
|
async hashPassword(password) {
|
154
160
|
return new Promise((resolve, reject) => {
|