@ebubekirylmaz/link-test 1.2.39 → 1.2.41

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebubekirylmaz/link-test",
3
- "version": "1.2.39",
3
+ "version": "1.2.41",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -103,8 +103,6 @@ function ProjectBar() {
103
103
  if (identityProvider === "DEMO") {
104
104
  payload.username = "admin";
105
105
  payload.password = "admin";
106
- } else if (identityProvider === "COGNITO") {
107
- payload.refreshToken = storage.get("link", "refreshToken");
108
106
  } else {
109
107
  payload.refreshToken = storage.get("link", "refreshToken");
110
108
  }
@@ -1,5 +1,7 @@
1
1
  import config from "../../config/config";
2
2
  import { storage } from "@nucleoidjs/webstorage";
3
+ import { useNavigate } from "react-router-dom";
4
+ import { useSnackbar } from "notistack";
3
5
  import { useState } from "react";
4
6
 
5
7
  import { Button, Stack, TextField, Typography } from "@mui/material";
@@ -13,18 +15,19 @@ export default function CognitoLogin() {
13
15
  const [password, setPassword] = useState("");
14
16
  const [code, setCode] = useState("");
15
17
 
18
+ const navigate = useNavigate();
19
+ const { enqueueSnackbar } = useSnackbar();
20
+
16
21
  const { appId } = config();
17
22
 
18
23
  const handleLogin = async () => {
19
24
  try {
20
- await login(username, password);
25
+ await login(email, password);
21
26
 
22
27
  const tokens = await getTokens();
23
28
  if (!tokens?.accessToken)
24
29
  throw new Error("No Cognito access token received");
25
30
 
26
- storage.set("link", "cognitoRefresh", tokens.accessToken);
27
-
28
31
  const res = await fetch("/api/oauth", {
29
32
  method: "POST",
30
33
  headers: { "Content-Type": "application/json" },
@@ -44,29 +47,35 @@ export default function CognitoLogin() {
44
47
  storage.set("link", "refreshToken", data.refreshToken);
45
48
  storage.set("link", "identityProvider", "COGNITO");
46
49
 
47
- window.location.href = "/";
50
+ navigate("/");
48
51
  } catch (e) {
49
52
  console.error("Login error:", e);
50
- alert(e.message || "Login failed");
53
+ enqueueSnackbar(e.message || "Login failed", { variant: "error" });
51
54
  }
52
55
  };
53
56
 
54
57
  const handleSignup = async () => {
55
58
  try {
56
- await signup(username, password, email);
59
+ await signup(email, password, password);
60
+ enqueueSnackbar(
61
+ "Account created! Please check your email for the confirmation code.",
62
+ { variant: "success" }
63
+ );
57
64
  setMode("confirm");
58
65
  } catch (e) {
59
- alert(e.message || "Signup failed");
66
+ enqueueSnackbar(e.message || "Signup failed", { variant: "error" });
60
67
  }
61
68
  };
62
69
 
63
70
  const handleConfirm = async () => {
64
71
  try {
65
- await confirmSignup(username, code);
66
- alert("Account confirmed! You can now log in.");
72
+ await confirmSignup(email, code);
73
+ enqueueSnackbar("Account confirmed! You can now log in.", {
74
+ variant: "success",
75
+ });
67
76
  setMode("login");
68
77
  } catch (e) {
69
- alert(e.message || "Confirmation failed");
78
+ enqueueSnackbar(e.message || "Confirmation failed", { variant: "error" });
70
79
  }
71
80
  };
72
81
 
@@ -80,9 +89,9 @@ export default function CognitoLogin() {
80
89
 
81
90
  <Stack spacing={2}>
82
91
  <TextField
83
- label="Username or Email"
84
- value={username}
85
- onChange={(e) => setUsername(e.target.value)}
92
+ label="Email"
93
+ value={email}
94
+ onChange={(e) => setEmail(e.target.value)}
86
95
  />
87
96
 
88
97
  {mode === "signup" && (