@appconda/nextjs 1.0.114 → 1.0.115
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 +1 -1
- package/src/actions/actionClient.ts +6 -3
- package/src/actions/auth.ts +2 -1
- package/src/actions/authOptions.ts +1 -1
- package/src/client.ts +1 -1
- package/src/lib/env.ts +1 -1
- package/src/lib/jwt.ts +1 -1
- package/src/modules/account/actions.ts +1 -1
- package/src/modules/task/schema.ts +1 -1
- package/tsconfig.json +2 -0
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@appconda/nextjs",
|
3
3
|
"homepage": "https://appconda.io/support",
|
4
4
|
"description": "Appconda is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
5
|
-
"version": "1.0.
|
5
|
+
"version": "1.0.115",
|
6
6
|
"license": "BSD-3-Clause",
|
7
7
|
"main": "src/index.ts",
|
8
8
|
"types": "src/index.ts",
|
@@ -3,6 +3,7 @@ import { getServerSession } from "next-auth";
|
|
3
3
|
import { DEFAULT_SERVER_ERROR_MESSAGE, createSafeActionClient } from "next-safe-action";
|
4
4
|
import { authOptions } from "./authOptions";
|
5
5
|
import { AuthenticationError, AuthorizationError } from "../lib/errors";
|
6
|
+
import { getSDKForCurrentUser } from "../getSDKForCurrentUser";
|
6
7
|
|
7
8
|
|
8
9
|
export const actionClient = createSafeActionClient({
|
@@ -27,7 +28,8 @@ export const actionClient = createSafeActionClient({
|
|
27
28
|
|
28
29
|
|
29
30
|
export const authenticatedActionClient = actionClient.use(async ({ next }) => {
|
30
|
-
const
|
31
|
+
const options = authOptions();
|
32
|
+
const session = options ? await getServerSession(options) : null;
|
31
33
|
//@ts-ignore
|
32
34
|
if (!session?.user) {
|
33
35
|
throw new AuthenticationError("Not authenticated");
|
@@ -36,8 +38,9 @@ export const authenticatedActionClient = actionClient.use(async ({ next }) => {
|
|
36
38
|
//@ts-ignore
|
37
39
|
const userId = session.user.id;
|
38
40
|
|
39
|
-
|
40
|
-
const
|
41
|
+
// Get the SDK and use users.get method to fetch the user
|
42
|
+
const { users } = await getSDKForCurrentUser();
|
43
|
+
const user = await users.get(userId);
|
41
44
|
if (!user) {
|
42
45
|
throw new AuthorizationError("User not found");
|
43
46
|
}
|
package/src/actions/auth.ts
CHANGED
@@ -2,5 +2,6 @@ import { getServerSession } from "next-auth"
|
|
2
2
|
import { authOptions } from "./authOptions";
|
3
3
|
|
4
4
|
export const auth = async ()=> {
|
5
|
-
|
5
|
+
const options = authOptions();
|
6
|
+
return options ? await getServerSession(options) : null;
|
6
7
|
}
|
package/src/client.ts
CHANGED
package/src/lib/env.ts
CHANGED
package/src/lib/jwt.ts
CHANGED
@@ -69,7 +69,7 @@ export const verifyToken = async (token: string): Promise<JwtPayload> => {
|
|
69
69
|
}
|
70
70
|
|
71
71
|
// If no email provided, look up the user
|
72
|
-
const foundUser = null;/* await prisma.user.findUnique({
|
72
|
+
const foundUser: any = null;/* await prisma.user.findUnique({
|
73
73
|
where: { id: decryptedId },
|
74
74
|
}); */
|
75
75
|
|
@@ -10,7 +10,7 @@ export const CreateUser = actionClient
|
|
10
10
|
.schema(CreateUserSchema)
|
11
11
|
.action(async ({ parsedInput }): Promise<User> => {
|
12
12
|
try {
|
13
|
-
const { userId, email, password, name } = parsedInput;
|
13
|
+
const { userId, email, password, name } = parsedInput as any;
|
14
14
|
const { accounts } = await getSDKForCurrentUser();
|
15
15
|
return await accounts.create(userId, email, password, name);
|
16
16
|
|
package/tsconfig.json
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
"traceResolution": false,
|
20
20
|
"experimentalDecorators": true,
|
21
21
|
"emitDecoratorMetadata": true,
|
22
|
+
"strictNullChecks": true,
|
23
|
+
"exactOptionalPropertyTypes": true,
|
22
24
|
"outDir": "./dist",
|
23
25
|
"paths": {
|
24
26
|
"next-safe-action": ["./node_modules/next-safe-action/index.d.ts"]
|