@semapps/auth 0.4.0-alpha.14 → 0.4.0-alpha.17
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 +6 -2
- package/package.json +4 -4
- package/services/account.js +2 -2
- package/services/migration.js +2 -1
package/mixins/auth.sso.js
CHANGED
@@ -41,13 +41,17 @@ const AuthSSOMixin = {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
accountData = await ctx.call('auth.account.create', { uuid: profileData.uuid, email: profileData.email });
|
44
|
-
webId = await ctx.call('webid.create', { nick: accountData.username, ...profileData });
|
44
|
+
webId = await ctx.call('webid.create', this.pickWebIdData({ nick: accountData.username, ...profileData }));
|
45
45
|
newUser = true;
|
46
46
|
|
47
47
|
// Link the webId with the account
|
48
48
|
await ctx.call('auth.account.attachWebId', { accountUri: accountData['@id'], webId });
|
49
49
|
|
50
|
-
ctx.emit(
|
50
|
+
ctx.emit(
|
51
|
+
'auth.registered',
|
52
|
+
{ webId, profileData, accountData, ssoData },
|
53
|
+
{ meta: { webId: null, dataset: null } }
|
54
|
+
);
|
51
55
|
}
|
52
56
|
|
53
57
|
const token = await ctx.call('auth.jwt.generateToken', { payload: { webId } });
|
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.17",
|
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.17",
|
9
|
+
"@semapps/triplestore": "0.4.0-alpha.17",
|
10
10
|
"bcrypt": "^5.0.1",
|
11
11
|
"express-session": "^1.17.0",
|
12
12
|
"jsonwebtoken": "^8.5.1",
|
@@ -22,5 +22,5 @@
|
|
22
22
|
"publishConfig": {
|
23
23
|
"access": "public"
|
24
24
|
},
|
25
|
-
"gitHead": "
|
25
|
+
"gitHead": "82ae033aade5af9edb2c119040c2cb0478e9a712"
|
26
26
|
}
|
package/services/account.js
CHANGED
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
let { uuid, username, password, email, webId, ...rest } = ctx.params;
|
17
17
|
const hashedPassword = password ? await this.hashPassword(password) : undefined;
|
18
18
|
|
19
|
-
email = email.toLowerCase();
|
19
|
+
email = email && email.toLowerCase();
|
20
20
|
|
21
21
|
const emailExists = await ctx.call('auth.account.emailExists', { email });
|
22
22
|
if (emailExists) {
|
@@ -102,7 +102,7 @@ module.exports = {
|
|
102
102
|
methods: {
|
103
103
|
async isValidUsername(ctx, username) {
|
104
104
|
// Ensure the username has no space or special characters
|
105
|
-
if (!/^[a-z0-9
|
105
|
+
if (!/^[a-z0-9\-+_.]+$/.exec(username)) {
|
106
106
|
throw new Error('username.invalid');
|
107
107
|
}
|
108
108
|
|
package/services/migration.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
const { MIME_TYPES } = require('@semapps/mime-types');
|
2
|
+
const { getSlugFromUri } = require('@semapps/ldp');
|
2
3
|
|
3
4
|
module.exports = {
|
4
5
|
name: 'auth.migration',
|
@@ -13,7 +14,7 @@ module.exports = {
|
|
13
14
|
try {
|
14
15
|
await ctx.call('auth.account.create', {
|
15
16
|
email: user[emailPredicate],
|
16
|
-
username: user[usernamePredicate],
|
17
|
+
username: usernamePredicate ? user[usernamePredicate] : getSlugFromUri(user.id),
|
17
18
|
webId: user.id
|
18
19
|
});
|
19
20
|
} catch (e) {
|