@next-nest-auth/nextauth 0.0.6 → 0.0.7
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/LICENSE +1 -1
- package/README.md +8 -8
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025 Md Shafkat Hussain Tanvir
|
|
3
|
+
Copyright (c) 2025 Md Shafkat Hussain Tanvir <tanvir0604@gmail.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ You can use the `checkAuth` and `refreshToken` functions in your Next.js middlew
|
|
|
28
28
|
|
|
29
29
|
```typescript
|
|
30
30
|
import { NextRequest, NextResponse } from "next/server";
|
|
31
|
-
import { checkAuth, refreshToken } from "nextauth";
|
|
31
|
+
import { checkAuth, refreshToken } from "@next-nest-auth/nextauth";
|
|
32
32
|
|
|
33
33
|
export async function middleware(req: NextRequest) {
|
|
34
34
|
const protectedRoutes = ["/dashboard", "/profile", "/settings"];
|
|
@@ -62,7 +62,7 @@ export const config = {
|
|
|
62
62
|
This function authenticates the user and sets the access and refresh tokens in cookies.
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
|
-
import { authenticate } from "nextauth";
|
|
65
|
+
import { authenticate } from "@next-nest-auth/nextauth";
|
|
66
66
|
|
|
67
67
|
const response = await authenticate({
|
|
68
68
|
username: "user",
|
|
@@ -75,7 +75,7 @@ const response = await authenticate({
|
|
|
75
75
|
This function is responsible for refreshing the access token using the refresh token stored in cookies.
|
|
76
76
|
|
|
77
77
|
```typescript
|
|
78
|
-
import { refreshToken } from "nextauth";
|
|
78
|
+
import { refreshToken } from "@next-nest-auth/nextauth";
|
|
79
79
|
|
|
80
80
|
const refreshedResponse = await refreshToken(req);
|
|
81
81
|
```
|
|
@@ -85,7 +85,7 @@ const refreshedResponse = await refreshToken(req);
|
|
|
85
85
|
This function retrieves the user information from the access token.
|
|
86
86
|
|
|
87
87
|
```typescript
|
|
88
|
-
import { getUserInfo } from "nextauth";
|
|
88
|
+
import { getUserInfo } from "@next-nest-auth/nextauth";
|
|
89
89
|
|
|
90
90
|
const userInfo = await getUserInfo();
|
|
91
91
|
```
|
|
@@ -95,7 +95,7 @@ const userInfo = await getUserInfo();
|
|
|
95
95
|
These functions retrieve the current access token and refresh token from the cookies.
|
|
96
96
|
|
|
97
97
|
```typescript
|
|
98
|
-
import { getAccessToken, getRefreshToken } from "nextauth";
|
|
98
|
+
import { getAccessToken, getRefreshToken } from "@next-nest-auth/nextauth";
|
|
99
99
|
|
|
100
100
|
const accessToken = await getAccessToken();
|
|
101
101
|
const refreshToken = await getRefreshToken();
|
|
@@ -106,7 +106,7 @@ const refreshToken = await getRefreshToken();
|
|
|
106
106
|
This function checks if the user is authenticated by verifying the access token.
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
|
-
import { checkAuth } from "nextauth";
|
|
109
|
+
import { checkAuth } from "@next-nest-auth/nextauth";
|
|
110
110
|
|
|
111
111
|
const authenticated = await checkAuth();
|
|
112
112
|
```
|
|
@@ -116,7 +116,7 @@ const authenticated = await checkAuth();
|
|
|
116
116
|
This function deletes the access and refresh tokens from cookies.
|
|
117
117
|
|
|
118
118
|
```typescript
|
|
119
|
-
import { logout } from "nextauth";
|
|
119
|
+
import { logout } from "@next-nest-auth/nextauth";
|
|
120
120
|
|
|
121
121
|
await logout();
|
|
122
122
|
```
|
|
@@ -126,7 +126,7 @@ await logout();
|
|
|
126
126
|
These are helper functions to make authenticated HTTP requests using Axios.
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
|
-
import { get, post } from "nextauth";
|
|
129
|
+
import { get, post } from "@next-nest-auth/nextauth";
|
|
130
130
|
|
|
131
131
|
const data = await get("/some-api-endpoint");
|
|
132
132
|
const postData = await post("/some-api-endpoint", { someData: "value" });
|