@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.
@@ -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', { uuid: profileData.uuid, email: profileData.email });
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.23",
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.23",
9
- "@semapps/triplestore": "0.4.0-alpha.23",
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": "e8a2b43965bc6eb4df2b073d13b0e137304e9b58"
27
+ "gitHead": "f65a5a67d02782b0539d12ed482e8cc4149e5d36"
28
28
  }
@@ -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 = 1;
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
- username = email.split('@')[0].toLowerCase();
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) => {