authverse 1.1.2 → 1.1.4

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.cjs CHANGED
@@ -119,8 +119,6 @@ var authUiRun = async ({ folder }) => {
119
119
  `${componentPath}/SingUpComponent.tsx`,
120
120
  SignUpDestinationPath
121
121
  );
122
- const LogoutDestinationPath = import_path.default.join(destinationPath, "Logout.tsx");
123
- import_fs.default.copyFileSync(`${componentPath}/Logout.tsx`, LogoutDestinationPath);
124
122
  const authTemplatePath = import_path.default.resolve(
125
123
  __dirname,
126
124
  "./template/app-auth-uiDesign"
@@ -315,16 +313,6 @@ BETTER_AUTH_URL=http://localhost:3000
315
313
  );
316
314
  }
317
315
  }
318
- const serverPath = import_path2.default.join(projectDir, srcFolder, "server");
319
- if (!import_fs2.default.existsSync(serverPath)) {
320
- import_fs2.default.mkdirSync(serverPath, { recursive: true });
321
- }
322
- const userTemplatePath = import_path2.default.resolve(
323
- __dirname,
324
- "./template/server/user.ts"
325
- );
326
- const userDestinationPath = import_path2.default.join(serverPath, "user.ts");
327
- import_fs2.default.copyFileSync(userTemplatePath, userDestinationPath);
328
316
  const routeTemplatePath = import_path2.default.resolve(
329
317
  __dirname,
330
318
  "./template/api/route.ts"
@@ -506,16 +494,6 @@ BETTER_AUTH_URL=http://localhost:3000
506
494
  );
507
495
  import_fs3.default.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
508
496
  }
509
- const serverPath = import_path3.default.join(projectDir, srcFolder, "server");
510
- if (!import_fs3.default.existsSync(serverPath)) {
511
- import_fs3.default.mkdirSync(serverPath, { recursive: true });
512
- }
513
- const userTemplatePath = import_path3.default.resolve(
514
- __dirname,
515
- "./template/server/user.ts"
516
- );
517
- const userDestinationPath = import_path3.default.join(serverPath, "user.ts");
518
- import_fs3.default.copyFileSync(userTemplatePath, userDestinationPath);
519
497
  const routeTemplatePath = import_path3.default.resolve(
520
498
  __dirname,
521
499
  "./template/api/route.ts"
@@ -935,7 +913,7 @@ var initAnswer = async () => {
935
913
  };
936
914
 
937
915
  // index.ts
938
- var import_fs27 = require("fs");
916
+ var import_fs26 = require("fs");
939
917
 
940
918
  // cli/provider.ts
941
919
  var import_chalk11 = __toESM(require("chalk"), 1);
@@ -2163,33 +2141,14 @@ var forget = () => {
2163
2141
  }
2164
2142
  };
2165
2143
 
2166
- // script/detect-nextjs.ts
2167
- var import_fs23 = require("fs");
2168
- function isNextJsProject() {
2169
- if (!(0, import_fs23.existsSync)("./package.json")) return false;
2170
- try {
2171
- const pkg = JSON.parse((0, import_fs23.readFileSync)("./package.json", "utf8"));
2172
- const deps = {
2173
- ...pkg.dependencies,
2174
- ...pkg.devDependencies
2175
- };
2176
- return deps["next"] !== void 0;
2177
- } catch (err) {
2178
- return false;
2179
- }
2180
- }
2181
-
2182
- // index.ts
2183
- var import_chalk23 = __toESM(require("chalk"), 1);
2184
-
2185
2144
  // cli/verification.ts
2186
2145
  var import_chalk22 = __toESM(require("chalk"), 1);
2187
- var import_fs26 = __toESM(require("fs"), 1);
2146
+ var import_fs25 = __toESM(require("fs"), 1);
2188
2147
  var import_path25 = __toESM(require("path"), 1);
2189
2148
 
2190
2149
  // script/verifyNext.ts
2191
2150
  var import_chalk20 = __toESM(require("chalk"), 1);
2192
- var import_fs24 = __toESM(require("fs"), 1);
2151
+ var import_fs23 = __toESM(require("fs"), 1);
2193
2152
  var import_path23 = __toESM(require("path"), 1);
2194
2153
  var import_url19 = require("url");
2195
2154
  var import_meta19 = {};
@@ -2199,17 +2158,17 @@ var verifyNext = async () => {
2199
2158
  const __filename = (0, import_url19.fileURLToPath)(import_meta19.url);
2200
2159
  const __dirname = import_path23.default.dirname(__filename);
2201
2160
  const srcPath = import_path23.default.join(projectDir, "src");
2202
- const folder = import_fs24.default.existsSync(srcPath) ? "src" : "";
2161
+ const folder = import_fs23.default.existsSync(srcPath) ? "src" : "";
2203
2162
  const emailFilePath = import_path23.default.join(projectDir, folder, "lib", "email.ts");
2204
- if (!import_fs24.default.existsSync(emailFilePath)) {
2163
+ if (!import_fs23.default.existsSync(emailFilePath)) {
2205
2164
  await email();
2206
2165
  }
2207
2166
  const authFilePath = import_path23.default.join(projectDir, folder, "lib", "auth.ts");
2208
- if (!import_fs24.default.existsSync(authFilePath)) {
2167
+ if (!import_fs23.default.existsSync(authFilePath)) {
2209
2168
  console.log(import_chalk20.default.red("auth.ts file not found."));
2210
2169
  return;
2211
2170
  }
2212
- let content = import_fs24.default.readFileSync(authFilePath, "utf8");
2171
+ let content = import_fs23.default.readFileSync(authFilePath, "utf8");
2213
2172
  if (content.includes("emailAndPassword: {")) {
2214
2173
  const start = content.indexOf("emailAndPassword: {");
2215
2174
  let end = start;
@@ -2255,26 +2214,32 @@ var verifyNext = async () => {
2255
2214
  `;
2256
2215
  content = content.slice(0, insertAt + 2) + emailVerificationBlock + content.slice(insertAt + 2);
2257
2216
  }
2258
- if (!content.includes("EmailVerification")) {
2217
+ if (!content.includes("import EmailVerification")) {
2259
2218
  const lastImport = content.lastIndexOf("import");
2260
2219
  const nextLine = content.indexOf("\n", lastImport) + 1;
2261
2220
  const imports = `import EmailVerification from "@/components/email/EmailVerification";
2262
- import { sendEmail } from "./email";
2263
2221
  `;
2264
2222
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2265
2223
  }
2266
- import_fs24.default.writeFileSync(authFilePath, content, "utf8");
2224
+ if (!content.includes("import { sendEmail }")) {
2225
+ const lastImport = content.lastIndexOf("import");
2226
+ const nextLine = content.indexOf("\n", lastImport) + 1;
2227
+ const imports = `import { sendEmail } from "./email";
2228
+ `;
2229
+ content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2230
+ }
2231
+ import_fs23.default.writeFileSync(authFilePath, content, "utf8");
2267
2232
  const templatePath = import_path23.default.resolve(
2268
2233
  __dirname,
2269
2234
  "./template/email/EmailVerification.tsx"
2270
2235
  );
2271
2236
  const componentsDir = import_path23.default.join(projectDir, folder, "components", "email");
2272
- if (!import_fs24.default.existsSync(componentsDir)) {
2273
- import_fs24.default.mkdirSync(componentsDir, { recursive: true });
2237
+ if (!import_fs23.default.existsSync(componentsDir)) {
2238
+ import_fs23.default.mkdirSync(componentsDir, { recursive: true });
2274
2239
  }
2275
2240
  const destFile = import_path23.default.join(componentsDir, "EmailVerification.tsx");
2276
- if (import_fs24.default.existsSync(templatePath) && !import_fs24.default.existsSync(destFile)) {
2277
- import_fs24.default.copyFileSync(templatePath, destFile);
2241
+ if (import_fs23.default.existsSync(templatePath) && !import_fs23.default.existsSync(destFile)) {
2242
+ import_fs23.default.copyFileSync(templatePath, destFile);
2278
2243
  }
2279
2244
  console.log(import_chalk20.default.green("Email verification successfully configured"));
2280
2245
  } catch (error) {
@@ -2284,7 +2249,7 @@ import { sendEmail } from "./email";
2284
2249
 
2285
2250
  // script/verifyTanstack.ts
2286
2251
  var import_chalk21 = __toESM(require("chalk"), 1);
2287
- var import_fs25 = __toESM(require("fs"), 1);
2252
+ var import_fs24 = __toESM(require("fs"), 1);
2288
2253
  var import_path24 = __toESM(require("path"), 1);
2289
2254
  var import_url20 = require("url");
2290
2255
  var import_meta20 = {};
@@ -2295,15 +2260,15 @@ var verifyTanstack = async () => {
2295
2260
  const __dirname = import_path24.default.dirname(__filename);
2296
2261
  const srcPath = import_path24.default.join(projectDir, "src");
2297
2262
  const emailFilePath = import_path24.default.join(srcPath, "lib", "email.ts");
2298
- if (!import_fs25.default.existsSync(emailFilePath)) {
2263
+ if (!import_fs24.default.existsSync(emailFilePath)) {
2299
2264
  await email();
2300
2265
  }
2301
2266
  const authFilePath = import_path24.default.join(srcPath, "lib", "auth.ts");
2302
- if (!import_fs25.default.existsSync(authFilePath)) {
2267
+ if (!import_fs24.default.existsSync(authFilePath)) {
2303
2268
  console.log(import_chalk21.default.red("auth.ts file not found."));
2304
2269
  return;
2305
2270
  }
2306
- let content = import_fs25.default.readFileSync(authFilePath, "utf8");
2271
+ let content = import_fs24.default.readFileSync(authFilePath, "utf8");
2307
2272
  if (content.includes("emailAndPassword: {")) {
2308
2273
  const start = content.indexOf("emailAndPassword: {");
2309
2274
  let end = start;
@@ -2349,26 +2314,32 @@ var verifyTanstack = async () => {
2349
2314
  `;
2350
2315
  content = content.slice(0, insertAt + 2) + emailVerificationBlock + content.slice(insertAt + 2);
2351
2316
  }
2352
- if (!content.includes("EmailVerification")) {
2317
+ if (!content.includes("import EmailVerification")) {
2353
2318
  const lastImport = content.lastIndexOf("import");
2354
2319
  const nextLine = content.indexOf("\n", lastImport) + 1;
2355
2320
  const imports = `import EmailVerification from "@/components/email/EmailVerification";
2356
- import { sendEmail } from "./email";
2357
2321
  `;
2358
2322
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2359
2323
  }
2360
- import_fs25.default.writeFileSync(authFilePath, content, "utf8");
2324
+ if (!content.includes("import { sendEmail }")) {
2325
+ const lastImport = content.lastIndexOf("import");
2326
+ const nextLine = content.indexOf("\n", lastImport) + 1;
2327
+ const imports = `import { sendEmail } from "./email";
2328
+ `;
2329
+ content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2330
+ }
2331
+ import_fs24.default.writeFileSync(authFilePath, content, "utf8");
2361
2332
  const templatePath = import_path24.default.resolve(
2362
2333
  __dirname,
2363
2334
  "./template/email/EmailVerification.tsx"
2364
2335
  );
2365
2336
  const componentsDir = import_path24.default.join(srcPath, "components", "email");
2366
- if (!import_fs25.default.existsSync(componentsDir)) {
2367
- import_fs25.default.mkdirSync(componentsDir, { recursive: true });
2337
+ if (!import_fs24.default.existsSync(componentsDir)) {
2338
+ import_fs24.default.mkdirSync(componentsDir, { recursive: true });
2368
2339
  }
2369
2340
  const destFile = import_path24.default.join(componentsDir, "EmailVerification.tsx");
2370
- if (import_fs25.default.existsSync(templatePath) && !import_fs25.default.existsSync(destFile)) {
2371
- import_fs25.default.copyFileSync(templatePath, destFile);
2341
+ if (import_fs24.default.existsSync(templatePath) && !import_fs24.default.existsSync(destFile)) {
2342
+ import_fs24.default.copyFileSync(templatePath, destFile);
2372
2343
  }
2373
2344
  console.log(import_chalk21.default.green("Email verification successfully configured"));
2374
2345
  } catch (error) {
@@ -2382,8 +2353,8 @@ var verification = async () => {
2382
2353
  const projectDir = process.cwd();
2383
2354
  const packageJsonPath = import_path25.default.join(projectDir, "package.json");
2384
2355
  let framework = "tanstack state";
2385
- if (import_fs26.default.existsSync(packageJsonPath)) {
2386
- const packageJson2 = JSON.parse(import_fs26.default.readFileSync(packageJsonPath, "utf-8"));
2356
+ if (import_fs25.default.existsSync(packageJsonPath)) {
2357
+ const packageJson2 = JSON.parse(import_fs25.default.readFileSync(packageJsonPath, "utf-8"));
2387
2358
  const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
2388
2359
  framework = hasNext ? "Next js" : "tanstack state";
2389
2360
  }
@@ -2399,19 +2370,15 @@ var verification = async () => {
2399
2370
  };
2400
2371
 
2401
2372
  // index.ts
2402
- var packageJson = JSON.parse((0, import_fs27.readFileSync)("./package.json", "utf8"));
2373
+ var packageJson = JSON.parse((0, import_fs26.readFileSync)("./package.json", "utf8"));
2403
2374
  var program = new import_commander.Command();
2404
2375
  program.name("authverse").description("CLI tool for creating authverse projects").version(
2405
2376
  packageJson.version || "1.0.0",
2406
2377
  "-v, --version",
2407
2378
  "display the version number"
2408
2379
  );
2409
- program.command("init").description("Select project template and configuration").action(() => {
2410
- if (!isNextJsProject) {
2411
- console.log(import_chalk23.default.red("Only Next.js projects are supported."));
2412
- process.exit(1);
2413
- }
2414
- initAnswer();
2380
+ program.command("init").description("Select project template and configuration").action(async () => {
2381
+ await initAnswer();
2415
2382
  });
2416
2383
  program.command("add <provider>").description("Add a new authentication provider").action((provider) => providers({ provider }));
2417
2384
  program.command("forget").description("Forget stored configurations").action(forget);
package/dist/index.js CHANGED
@@ -96,8 +96,6 @@ var authUiRun = async ({ folder }) => {
96
96
  `${componentPath}/SingUpComponent.tsx`,
97
97
  SignUpDestinationPath
98
98
  );
99
- const LogoutDestinationPath = path.join(destinationPath, "Logout.tsx");
100
- fs.copyFileSync(`${componentPath}/Logout.tsx`, LogoutDestinationPath);
101
99
  const authTemplatePath = path.resolve(
102
100
  __dirname,
103
101
  "./template/app-auth-uiDesign"
@@ -291,16 +289,6 @@ BETTER_AUTH_URL=http://localhost:3000
291
289
  );
292
290
  }
293
291
  }
294
- const serverPath = path2.join(projectDir, srcFolder, "server");
295
- if (!fs2.existsSync(serverPath)) {
296
- fs2.mkdirSync(serverPath, { recursive: true });
297
- }
298
- const userTemplatePath = path2.resolve(
299
- __dirname,
300
- "./template/server/user.ts"
301
- );
302
- const userDestinationPath = path2.join(serverPath, "user.ts");
303
- fs2.copyFileSync(userTemplatePath, userDestinationPath);
304
292
  const routeTemplatePath = path2.resolve(
305
293
  __dirname,
306
294
  "./template/api/route.ts"
@@ -481,16 +469,6 @@ BETTER_AUTH_URL=http://localhost:3000
481
469
  );
482
470
  fs3.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
483
471
  }
484
- const serverPath = path3.join(projectDir, srcFolder, "server");
485
- if (!fs3.existsSync(serverPath)) {
486
- fs3.mkdirSync(serverPath, { recursive: true });
487
- }
488
- const userTemplatePath = path3.resolve(
489
- __dirname,
490
- "./template/server/user.ts"
491
- );
492
- const userDestinationPath = path3.join(serverPath, "user.ts");
493
- fs3.copyFileSync(userTemplatePath, userDestinationPath);
494
472
  const routeTemplatePath = path3.resolve(
495
473
  __dirname,
496
474
  "./template/api/route.ts"
@@ -907,7 +885,7 @@ var initAnswer = async () => {
907
885
  };
908
886
 
909
887
  // index.ts
910
- import { readFileSync as readFileSync2 } from "fs";
888
+ import { readFileSync } from "fs";
911
889
 
912
890
  // cli/provider.ts
913
891
  import chalk11 from "chalk";
@@ -2123,25 +2101,6 @@ var forget = () => {
2123
2101
  }
2124
2102
  };
2125
2103
 
2126
- // script/detect-nextjs.ts
2127
- import { existsSync, readFileSync } from "fs";
2128
- function isNextJsProject() {
2129
- if (!existsSync("./package.json")) return false;
2130
- try {
2131
- const pkg = JSON.parse(readFileSync("./package.json", "utf8"));
2132
- const deps = {
2133
- ...pkg.dependencies,
2134
- ...pkg.devDependencies
2135
- };
2136
- return deps["next"] !== void 0;
2137
- } catch (err) {
2138
- return false;
2139
- }
2140
- }
2141
-
2142
- // index.ts
2143
- import chalk23 from "chalk";
2144
-
2145
2104
  // cli/verification.ts
2146
2105
  import chalk22 from "chalk";
2147
2106
  import fs25 from "fs";
@@ -2214,11 +2173,17 @@ var verifyNext = async () => {
2214
2173
  `;
2215
2174
  content = content.slice(0, insertAt + 2) + emailVerificationBlock + content.slice(insertAt + 2);
2216
2175
  }
2217
- if (!content.includes("EmailVerification")) {
2176
+ if (!content.includes("import EmailVerification")) {
2218
2177
  const lastImport = content.lastIndexOf("import");
2219
2178
  const nextLine = content.indexOf("\n", lastImport) + 1;
2220
2179
  const imports = `import EmailVerification from "@/components/email/EmailVerification";
2221
- import { sendEmail } from "./email";
2180
+ `;
2181
+ content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2182
+ }
2183
+ if (!content.includes("import { sendEmail }")) {
2184
+ const lastImport = content.lastIndexOf("import");
2185
+ const nextLine = content.indexOf("\n", lastImport) + 1;
2186
+ const imports = `import { sendEmail } from "./email";
2222
2187
  `;
2223
2188
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2224
2189
  }
@@ -2307,11 +2272,17 @@ var verifyTanstack = async () => {
2307
2272
  `;
2308
2273
  content = content.slice(0, insertAt + 2) + emailVerificationBlock + content.slice(insertAt + 2);
2309
2274
  }
2310
- if (!content.includes("EmailVerification")) {
2275
+ if (!content.includes("import EmailVerification")) {
2311
2276
  const lastImport = content.lastIndexOf("import");
2312
2277
  const nextLine = content.indexOf("\n", lastImport) + 1;
2313
2278
  const imports = `import EmailVerification from "@/components/email/EmailVerification";
2314
- import { sendEmail } from "./email";
2279
+ `;
2280
+ content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2281
+ }
2282
+ if (!content.includes("import { sendEmail }")) {
2283
+ const lastImport = content.lastIndexOf("import");
2284
+ const nextLine = content.indexOf("\n", lastImport) + 1;
2285
+ const imports = `import { sendEmail } from "./email";
2315
2286
  `;
2316
2287
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2317
2288
  }
@@ -2357,19 +2328,15 @@ var verification = async () => {
2357
2328
  };
2358
2329
 
2359
2330
  // index.ts
2360
- var packageJson = JSON.parse(readFileSync2("./package.json", "utf8"));
2331
+ var packageJson = JSON.parse(readFileSync("./package.json", "utf8"));
2361
2332
  var program = new Command();
2362
2333
  program.name("authverse").description("CLI tool for creating authverse projects").version(
2363
2334
  packageJson.version || "1.0.0",
2364
2335
  "-v, --version",
2365
2336
  "display the version number"
2366
2337
  );
2367
- program.command("init").description("Select project template and configuration").action(() => {
2368
- if (!isNextJsProject) {
2369
- console.log(chalk23.red("Only Next.js projects are supported."));
2370
- process.exit(1);
2371
- }
2372
- initAnswer();
2338
+ program.command("init").description("Select project template and configuration").action(async () => {
2339
+ await initAnswer();
2373
2340
  });
2374
2341
  program.command("add <provider>").description("Add a new authentication provider").action((provider) => providers({ provider }));
2375
2342
  program.command("forget").description("Forget stored configurations").action(forget);
@@ -1,5 +1,4 @@
1
1
  import { useForm } from "@tanstack/react-form";
2
- // import { Controller } from "@tanstack/react-form";
3
2
  import { toast } from "sonner";
4
3
  import * as z from "zod";
5
4
  import { Button } from "@/components/ui/button";
@@ -4,7 +4,6 @@ import { Controller, useForm } from "react-hook-form";
4
4
  import { toast } from "sonner";
5
5
  import * as z from "zod";
6
6
  import { zodResolver } from "@hookform/resolvers/zod";
7
-
8
7
  import { Button } from "@/components/ui/button";
9
8
  import {
10
9
  Card,
@@ -23,8 +22,8 @@ import {
23
22
  import { Input } from "@/components/ui/input";
24
23
  import Link from "next/link";
25
24
  import { useState } from "react";
26
- import { signIn } from "@/server/user";
27
25
  import { useRouter } from "next/navigation";
26
+ import { authClient } from "@/lib/auth-client";
28
27
 
29
28
  const formSchema = z.object({
30
29
  email: z.string().email(),
@@ -47,20 +46,24 @@ const LoginComponent = () => {
47
46
 
48
47
  const onSubmit = async (data: z.infer<typeof formSchema>) => {
49
48
  setIsLoading(true);
50
- try {
51
- const { success, message } = await signIn(data.email, data.password);
52
-
53
- if (success === true) {
54
- router.push("/");
55
- toast.success(message);
56
- } else {
57
- toast.error(message);
49
+ await authClient.signIn.email(
50
+ {
51
+ email: data.email,
52
+ password: data.password,
53
+ callbackURL: "/",
54
+ },
55
+ {
56
+ onSuccess: (data) => {
57
+ toast.success("Login successful!");
58
+ setIsLoading(false);
59
+ router.push("/");
60
+ },
61
+ onError: (error: any) => {
62
+ setIsLoading(false);
63
+ toast.error(error.error.message);
64
+ },
58
65
  }
59
- setIsLoading(false);
60
- } catch (error: any) {
61
- toast.error(error.message);
62
- setIsLoading(false);
63
- }
66
+ );
64
67
  };
65
68
 
66
69
  return (
@@ -4,7 +4,6 @@ import { Controller, useForm } from "react-hook-form";
4
4
  import { toast } from "sonner";
5
5
  import * as z from "zod";
6
6
  import { zodResolver } from "@hookform/resolvers/zod";
7
-
8
7
  import { Button } from "@/components/ui/button";
9
8
  import {
10
9
  Card,
@@ -23,14 +22,14 @@ import {
23
22
  import { Input } from "@/components/ui/input";
24
23
  import Link from "next/link";
25
24
  import { useState } from "react";
26
- import { signUp } from "@/server/user";
27
25
  import { useRouter } from "next/navigation";
26
+ import { authClient } from "@/lib/auth-client";
28
27
 
29
28
  const formSchema = z.object({
30
29
  name: z.string().min(3, {
31
30
  message: "Name must be at least 3 characters",
32
31
  }),
33
- email: z.string().email(),
32
+ email: z.email(),
34
33
  password: z.string().min(8, {
35
34
  message: "Password must be at least 8 characters",
36
35
  }),
@@ -51,24 +50,25 @@ const SingUpComponent = () => {
51
50
 
52
51
  const onSubmit = async (data: z.infer<typeof formSchema>) => {
53
52
  setIsLoading(true);
54
- try {
55
- const { success, message } = await signUp(
56
- data.name,
57
- data.email,
58
- data.password
59
- );
60
-
61
- if (success === true) {
62
- router.push("/");
63
- toast.success(message);
64
- } else {
65
- toast.error(message);
53
+ await authClient.signUp.email(
54
+ {
55
+ name: data.name,
56
+ email: data.email,
57
+ password: data.password,
58
+ callbackURL: "/",
59
+ },
60
+ {
61
+ onSuccess: () => {
62
+ toast.success("Sign up successful!");
63
+ setIsLoading(false);
64
+ router.push("/");
65
+ },
66
+ onError: (error: any) => {
67
+ setIsLoading(false);
68
+ toast.error(error.error.message);
69
+ },
66
70
  }
67
- setIsLoading(false);
68
- } catch (error: any) {
69
- toast.error(error.message);
70
- setIsLoading(false);
71
- }
71
+ );
72
72
  };
73
73
 
74
74
  return (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authverse",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Authverse Fast modern CLI to generate full auth systems with OAuth Prisma Drizzle better auth and ready-to-use ShadCN UI screens",
5
5
  "repository": {
6
6
  "url": "git+https://github.com/abdirahmanmahamoud/authverse.git",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "chalk": "^5.6.2",
49
49
  "commander": "^14.0.2",
50
- "inquirer": "^13.1.0"
50
+ "inquirer": "^12.10.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@semantic-release/changelog": "^6.0.3",
@@ -56,7 +56,7 @@
56
56
  "@semantic-release/github": "^12.0.2",
57
57
  "@semantic-release/npm": "^13.1.2",
58
58
  "@semantic-release/release-notes-generator": "^14.1.0",
59
- "@types/node": "^25.0.6",
59
+ "@types/node": "^25.0.8",
60
60
  "conventional-changelog-conventionalcommits": "^9.1.0",
61
61
  "semantic-release": "^25.0.2",
62
62
  "tsup": "^8.5.0",
@@ -1,21 +0,0 @@
1
- "use client";
2
- import { Button } from "@/components/ui/button";
3
- import { authClient } from "@/lib/auth-client";
4
- import { LogOutIcon } from "lucide-react";
5
- import { useRouter } from "next/navigation";
6
-
7
- const Logout = () => {
8
- const router = useRouter();
9
- const handleLogout = async () => {
10
- await authClient.signOut();
11
- router.push("/auth/login");
12
- };
13
- return (
14
- <Button variant="outline" onClick={handleLogout}>
15
- <LogOutIcon className="mr-1 h-4 w-4" />
16
- Logout
17
- </Button>
18
- );
19
- };
20
-
21
- export default Logout;
@@ -1,49 +0,0 @@
1
- "use server";
2
- import { auth } from "@/lib/auth";
3
-
4
- export const signIn = async (email: string, password: string) => {
5
- try {
6
- await auth.api.signInEmail({
7
- body: {
8
- email,
9
- password,
10
- },
11
- });
12
-
13
- return {
14
- success: true,
15
- message: "Login successfully.",
16
- };
17
- } catch (error) {
18
- const e = error as Error;
19
-
20
- return {
21
- success: false,
22
- message: e.message || "An unknown error occurred.",
23
- };
24
- }
25
- };
26
-
27
- export const signUp = async (name: string, email: string, password: string) => {
28
- try {
29
- await auth.api.signUpEmail({
30
- body: {
31
- name,
32
- email,
33
- password,
34
- },
35
- });
36
-
37
- return {
38
- success: true,
39
- message: "Signed up successfully.",
40
- };
41
- } catch (error) {
42
- const e = error as Error;
43
-
44
- return {
45
- success: false,
46
- message: e.message || "An unknown error occurred.",
47
- };
48
- }
49
- };