Skip to content

Commit 5165aec

Browse files
committed
small enhancements
1 parent 515d670 commit 5165aec

File tree

1 file changed

+7
-8
lines changed
  • motoko/internet_identity_integration/src/greet_frontend/src

1 file changed

+7
-8
lines changed

motoko/internet_identity_integration/src/greet_frontend/src/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import { createActor, greet_backend } from "../../declarations/greet_backend";
22
import { AuthClient } from "@dfinity/auth-client";
33
import { HttpAgent } from "@dfinity/agent";
44

5-
/**
6-
* Put this on the window so we can access it from the console.
7-
* This is helpful for learning, but it's recommended to keep it in a closure in a real app.
8-
*
9-
* We can use the default (not authenticated) greet_backend actor to call the greet method, and then update it once the authClient is ready, and again when the user logs in.
10-
*/
11-
window.greetActor = greet_backend;
5+
// Global variables that we will set up
6+
window.greetActor;
7+
window.authClient;
128

139
const greetButton = document.getElementById("greet");
1410
const loginButton = document.getElementById("login");
@@ -24,13 +20,16 @@ AuthClient.create().then((client) => {
2420
greetButton.removeAttribute("disabled");
2521
});
2622

27-
loginButton.onclick = async () => {
23+
loginButton.onclick = () => {
2824
// start the login process and wait for it to finish
2925
window.authClient.login({
3026
identityProvider: process.env.II_URL,
3127
onSuccess: () => {
3228
setActor(window.authClient);
3329
},
30+
onError: (err) => {
31+
console.error(err);
32+
},
3433
});
3534
};
3635

0 commit comments

Comments
 (0)