next-auth-mfelfelani72 0.0.48 → 0.0.50

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.
@@ -1,17 +1,17 @@
1
1
  /*
2
- * @Author: Mohammad Felfelani
3
- * @Email: mfelfelani72@gmail.com
4
- * @Team:
5
- * @Date: 2025-12-31 06:00:17
6
- * @Description: Register handler with Next.js native cookies
7
- */
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-12-31 06:00:17
6
+ * @Description: Register handler with Next.js native cookies
7
+ */
8
8
  import { cookies } from "next/headers";
9
9
  import { NextResponse, } from "next/server";
10
10
  // Functions
11
11
  import { cns } from "forma-li";
12
12
  export function registerHandler(apiUrl) {
13
13
  return async function POST(req) {
14
- var _a, _b, _c, _d;
14
+ var _a, _b, _c;
15
15
  try {
16
16
  const body = await req.json();
17
17
  const { name, email, password, confirmPassword, } = body;
@@ -77,6 +77,7 @@ export function registerHandler(apiUrl) {
77
77
  body: payload,
78
78
  route: "/register",
79
79
  });
80
+ console.log("REGISTER BACKEND RESPONSE:", data);
80
81
  if (!data) {
81
82
  return NextResponse.json({
82
83
  message: "No response from server",
@@ -84,7 +85,7 @@ export function registerHandler(apiUrl) {
84
85
  }, { status: 500 });
85
86
  }
86
87
  if (data.success &&
87
- ((_a = data.data) === null || _a === void 0 ? void 0 : _a.user)) {
88
+ ((_a = data.data) === null || _a === void 0 ? void 0 : _a.access_token)) {
88
89
  const cookieStore = await cookies();
89
90
  const returnTo = (_b = cookieStore.get("returnTo")) === null || _b === void 0 ? void 0 : _b.value;
90
91
  const lastVisited = (_c = cookieStore.get("lastVisited")) === null || _c === void 0 ? void 0 : _c.value;
@@ -110,18 +111,18 @@ export function registerHandler(apiUrl) {
110
111
  path: "/",
111
112
  maxAge: 60 * 60 * 24 * 7,
112
113
  };
113
- if ((_d = data.data.token) === null || _d === void 0 ? void 0 : _d.access_token) {
114
- res.cookies.set(Object.assign(Object.assign({ name: "app_key", value: JSON.stringify({
115
- tk: data.data.token
116
- .access_token,
117
- ud: data.data.user.uuid ||
118
- data.data.user.id,
119
- }) }, cookieOptions), { httpOnly: false }));
120
- res.cookies.set(Object.assign(Object.assign({ name: "key_type", value: data.data.token
121
- .token_type ||
122
- "Bearer" }, cookieOptions), { httpOnly: false }));
123
- }
114
+ // Auth token
115
+ res.cookies.set(Object.assign(Object.assign({ name: "app_key", value: JSON.stringify({
116
+ tk: data.data.access_token,
117
+ ud: data.data.user.uuid ||
118
+ data.data.user.id,
119
+ }) }, cookieOptions), { httpOnly: false }));
120
+ // Token type
121
+ res.cookies.set(Object.assign(Object.assign({ name: "key_type", value: data.data.token_type ||
122
+ "Bearer" }, cookieOptions), { httpOnly: false }));
123
+ // User
124
124
  res.cookies.set(Object.assign(Object.assign({ name: "user", value: JSON.stringify(data.data.user) }, cookieOptions), { httpOnly: false }));
125
+ // Authentication state
125
126
  res.cookies.set(Object.assign(Object.assign({ name: "isLoggedIn", value: "true" }, cookieOptions), { httpOnly: false }));
126
127
  return res;
127
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-auth-mfelfelani72",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [