@semapps/auth 0.4.0-alpha.3 → 0.4.0-alpha.4
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/package.json +4 -4
- package/services/account.js +5 -6
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.4",
|
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.4",
|
9
|
+
"@semapps/triplestore": "0.4.0-alpha.4",
|
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": "2ba923a2a0799a03a99cbe9af67f0a1b3bdda139"
|
26
26
|
}
|
package/services/account.js
CHANGED
@@ -54,11 +54,10 @@ module.exports = {
|
|
54
54
|
async verify(ctx) {
|
55
55
|
const { username, password } = ctx.params;
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
});
|
57
|
+
// If the username includes a @, assume it is an email
|
58
|
+
const query = username.includes('@') ? { email: username } : { username };
|
59
|
+
|
60
|
+
const accounts = await this._find(ctx, { query });
|
62
61
|
|
63
62
|
if (accounts.length > 0) {
|
64
63
|
const passwordMatch = await this.comparePassword(password, accounts[0].hashedPassword);
|
@@ -100,7 +99,7 @@ module.exports = {
|
|
100
99
|
methods: {
|
101
100
|
async isValidUsername(ctx, username) {
|
102
101
|
// Ensure the username has no space or special characters
|
103
|
-
if (!/^[a-
|
102
|
+
if (!/^[a-z0-9\-_.]+$/.exec(username)) {
|
104
103
|
throw new Error('username.invalid');
|
105
104
|
}
|
106
105
|
|