@ebubekirylmaz/link-test 1.2.28 → 1.2.29
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,5 +1,6 @@
|
|
|
1
1
|
import { Button, Stack, TextField, Typography } from "@mui/material";
|
|
2
|
-
import { confirmSignup, login, signup } from "./amplifyAuth";
|
|
2
|
+
import { confirmSignup, login, signup, getTokens } from "./amplifyAuth";
|
|
3
|
+
import { storage } from "@nucleoidjs/webstorage";
|
|
3
4
|
|
|
4
5
|
import { storage } from "@nucleoidjs/webstorage";
|
|
5
6
|
import { useState } from "react";
|
|
@@ -15,8 +16,21 @@ export default function CognitoLogin() {
|
|
|
15
16
|
const handleLogin = async () => {
|
|
16
17
|
try {
|
|
17
18
|
await login(username, password);
|
|
19
|
+
|
|
20
|
+
const tokens = await getTokens();
|
|
21
|
+
|
|
22
|
+
if (!tokens?.accessToken) {
|
|
23
|
+
throw new Error("No access token received");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
storage.set("oauth", "access_token", tokens.accessToken);
|
|
27
|
+
storage.set("oauth", "refresh_token", tokens.refreshToken);
|
|
28
|
+
storage.set("oauth", "id_token", tokens.idToken);
|
|
29
|
+
storage.set("oauth", "provider", "cognito");
|
|
30
|
+
|
|
18
31
|
window.location.href = "/";
|
|
19
32
|
} catch (e) {
|
|
33
|
+
console.error("Login error:", e);
|
|
20
34
|
alert(e.message || "Login failed");
|
|
21
35
|
}
|
|
22
36
|
};
|