tinacms-authjs 10.0.6 → 10.0.8
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/dist/index.js +9 -13
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -45,10 +45,9 @@ var TINA_CREDENTIALS_PROVIDER_NAME = "TinaCredentials";
|
|
|
45
45
|
|
|
46
46
|
// src/index.ts
|
|
47
47
|
var authenticate = async (databaseClient, username, password) => {
|
|
48
|
-
var _a;
|
|
49
48
|
try {
|
|
50
49
|
const result = await databaseClient.authenticate({ username, password });
|
|
51
|
-
return
|
|
50
|
+
return result.data?.authenticate || null;
|
|
52
51
|
} catch (e) {
|
|
53
52
|
console.error(e);
|
|
54
53
|
}
|
|
@@ -64,17 +63,16 @@ var TinaAuthJSOptions = ({
|
|
|
64
63
|
}) => ({
|
|
65
64
|
callbacks: {
|
|
66
65
|
jwt: async ({ token: jwt, account }) => {
|
|
67
|
-
var _a, _b, _c, _d;
|
|
68
66
|
if (account) {
|
|
69
67
|
if (debug) {
|
|
70
68
|
console.table(jwt);
|
|
71
69
|
}
|
|
72
70
|
try {
|
|
73
|
-
if (jwt
|
|
71
|
+
if (jwt?.[uidProp]) {
|
|
74
72
|
const sub = jwt[uidProp];
|
|
75
73
|
const result = await databaseClient.authorize({ sub });
|
|
76
|
-
jwt.role = !!
|
|
77
|
-
jwt.passwordChangeRequired =
|
|
74
|
+
jwt.role = !!result.data?.authorize ? "user" : "guest";
|
|
75
|
+
jwt.passwordChangeRequired = result.data?.authorize?._password?.passwordChangeRequired || false;
|
|
78
76
|
} else if (debug) {
|
|
79
77
|
console.log(`jwt missing specified uidProp: ${uidProp}`);
|
|
80
78
|
}
|
|
@@ -118,8 +116,7 @@ var AuthJsBackendAuthProvider = ({
|
|
|
118
116
|
}) => {
|
|
119
117
|
const authProvider = {
|
|
120
118
|
initialize: async () => {
|
|
121
|
-
|
|
122
|
-
if (!((_a = authOptions.providers) == null ? void 0 : _a.length)) {
|
|
119
|
+
if (!authOptions.providers?.length) {
|
|
123
120
|
throw new Error("No auth providers specified");
|
|
124
121
|
}
|
|
125
122
|
const [provider, ...rest] = authOptions.providers;
|
|
@@ -137,14 +134,14 @@ var AuthJsBackendAuthProvider = ({
|
|
|
137
134
|
writable: false
|
|
138
135
|
});
|
|
139
136
|
}
|
|
140
|
-
if (!
|
|
137
|
+
if (!session?.user) {
|
|
141
138
|
return {
|
|
142
139
|
errorCode: 401,
|
|
143
140
|
errorMessage: "Unauthorized",
|
|
144
141
|
isAuthorized: false
|
|
145
142
|
};
|
|
146
143
|
}
|
|
147
|
-
if ((session
|
|
144
|
+
if ((session?.user).role !== "user") {
|
|
148
145
|
return {
|
|
149
146
|
errorCode: 403,
|
|
150
147
|
errorMessage: "Forbidden",
|
|
@@ -157,12 +154,11 @@ var AuthJsBackendAuthProvider = ({
|
|
|
157
154
|
auth: {
|
|
158
155
|
secure: false,
|
|
159
156
|
handler: async (req, res, opts) => {
|
|
160
|
-
var _a, _b, _c;
|
|
161
157
|
const url = new URL(
|
|
162
158
|
req.url,
|
|
163
|
-
`http://${
|
|
159
|
+
`http://${req.headers?.host || "localhost"}`
|
|
164
160
|
);
|
|
165
|
-
const authSubRoutes =
|
|
161
|
+
const authSubRoutes = url.pathname?.replace(`${opts.basePath}auth/`, "")?.split("/");
|
|
166
162
|
req.query.nextauth = authSubRoutes;
|
|
167
163
|
await (0, import_next_auth.default)(authOptions)(req, res);
|
|
168
164
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms-authjs",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"files": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tinacms/schema-tools": "1.7.
|
|
21
|
+
"@tinacms/schema-tools": "1.7.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"next": "14.2.10",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"react": "^18.3.1",
|
|
27
27
|
"react-dom": "^18.3.1",
|
|
28
28
|
"typescript": "^5.7.3",
|
|
29
|
-
"@tinacms/
|
|
30
|
-
"@tinacms/
|
|
31
|
-
"tinacms": "2.7.
|
|
29
|
+
"@tinacms/datalayer": "1.3.18",
|
|
30
|
+
"@tinacms/scripts": "1.3.5",
|
|
31
|
+
"tinacms": "2.7.8"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"next": "^12.2.5 || ^13 || ^14",
|
|
35
35
|
"next-auth": "^4.22.1",
|
|
36
36
|
"react": "^17.0.2 || ^18",
|
|
37
37
|
"react-dom": "^17.0.2 || ^18",
|
|
38
|
-
"tinacms": "2.7.
|
|
38
|
+
"tinacms": "2.7.8"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"registry": "https://registry.npmjs.org"
|