@semapps/auth 0.4.1 → 0.4.2
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
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@semapps/auth",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.2",
|
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.
|
9
|
-
"@semapps/triplestore": "0.4.
|
8
|
+
"@semapps/mime-types": "0.4.2",
|
9
|
+
"@semapps/triplestore": "0.4.2",
|
10
10
|
"bcrypt": "^5.0.1",
|
11
11
|
"express-session": "^1.17.0",
|
12
12
|
"jsonwebtoken": "^8.5.1",
|
@@ -25,5 +25,5 @@
|
|
25
25
|
"publishConfig": {
|
26
26
|
"access": "public"
|
27
27
|
},
|
28
|
-
"gitHead": "
|
28
|
+
"gitHead": "f63b346f1ce7d15a6c630dc4afe528d7b2a0526c"
|
29
29
|
}
|
package/services/auth.local.js
CHANGED
@@ -14,6 +14,7 @@ const AuthLocalService = {
|
|
14
14
|
reservedUsernames: [],
|
15
15
|
webIdSelection: [],
|
16
16
|
accountSelection: [],
|
17
|
+
formUrl: null,
|
17
18
|
mail: {
|
18
19
|
from: null,
|
19
20
|
transport: {
|
@@ -71,6 +72,24 @@ const AuthLocalService = {
|
|
71
72
|
|
72
73
|
return { token, webId: accountData.webId, newUser: false };
|
73
74
|
},
|
75
|
+
async logout(ctx) {
|
76
|
+
ctx.meta.$statusCode = 302;
|
77
|
+
ctx.meta.$location = ctx.params.redirectUrl || this.settings.formUrl;
|
78
|
+
},
|
79
|
+
async redirectToForm(ctx) {
|
80
|
+
if (this.settings.formUrl) {
|
81
|
+
const formUrl = new URL(this.settings.formUrl);
|
82
|
+
if (ctx.params) {
|
83
|
+
for (let [key, value] of Object.entries(ctx.params)) {
|
84
|
+
formUrl.searchParams.set(key, value);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
ctx.meta.$statusCode = 302;
|
88
|
+
ctx.meta.$location = formUrl.toString();
|
89
|
+
} else {
|
90
|
+
throw new Error('No formUrl defined in auth.local settings')
|
91
|
+
}
|
92
|
+
},
|
74
93
|
async resetPassword(ctx) {
|
75
94
|
const { email } = ctx.params;
|
76
95
|
|
@@ -130,6 +149,14 @@ const AuthLocalService = {
|
|
130
149
|
}
|
131
150
|
};
|
132
151
|
|
152
|
+
const logoutRoute = {
|
153
|
+
path: '/auth/logout',
|
154
|
+
name: 'auth-logout',
|
155
|
+
aliases: {
|
156
|
+
'GET /': 'auth.logout'
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
133
160
|
const signupRoute = {
|
134
161
|
path: '/auth/signup',
|
135
162
|
name: 'auth-signup',
|
@@ -138,6 +165,14 @@ const AuthLocalService = {
|
|
138
165
|
}
|
139
166
|
};
|
140
167
|
|
168
|
+
const formRoute = {
|
169
|
+
path: '/auth',
|
170
|
+
name: 'auth',
|
171
|
+
aliases: {
|
172
|
+
'GET /': 'auth.redirectToForm'
|
173
|
+
}
|
174
|
+
};
|
175
|
+
|
141
176
|
const resetPasswordRoute = {
|
142
177
|
path: '/auth/reset_password',
|
143
178
|
name: 'auth-reset-password',
|
@@ -163,7 +198,7 @@ const AuthLocalService = {
|
|
163
198
|
authorization: true
|
164
199
|
};
|
165
200
|
|
166
|
-
const routes = [loginRoute, resetPasswordRoute, setNewPasswordRoute, accountSettingsRoute];
|
201
|
+
const routes = [loginRoute, logoutRoute, formRoute, resetPasswordRoute, setNewPasswordRoute, accountSettingsRoute];
|
167
202
|
|
168
203
|
if (this.settings.registrationAllowed) {
|
169
204
|
return [...routes, signupRoute];
|
package/services/mail.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
const MailService = require('moleculer-mail');
|
2
1
|
const path = require('path');
|
2
|
+
const urlJoin = require('url-join');
|
3
|
+
const MailService = require('moleculer-mail');
|
3
4
|
|
4
5
|
module.exports = {
|
5
6
|
name: 'auth.mail',
|
@@ -24,8 +25,7 @@ module.exports = {
|
|
24
25
|
locale: this.getTemplateLocale(account.preferredLocale || this.settings.defaults.locale),
|
25
26
|
data: {
|
26
27
|
account,
|
27
|
-
token
|
28
|
-
frontUrl: account.preferredFrontUrl || this.settings.defaults.frontUrl
|
28
|
+
resetUrl: urlJoin(this.settings.defaults.frontUrl, 'login') + '?new_password=true&token=' + token
|
29
29
|
}
|
30
30
|
},
|
31
31
|
{
|