File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
motoko/internet_identity_integration/src/greet_frontend/src Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,14 @@ import {HttpAgent} from "@dfinity/agent";
44
55let actor = greet_backend ;
66
7+ // create an auth client on page load.
8+ // Safari might block the popup if the app performs other async actions before opening the popup.
9+ // This is why we create the auth client here, and not in the loginButton click handler
10+ let authClient = undefined ;
11+ AuthClient . create ( ) . then ( ( client ) => {
12+ authClient = client ;
13+ } ) ;
14+
715const greetButton = document . getElementById ( "greet" ) ;
816greetButton . onclick = async ( e ) => {
917 e . preventDefault ( ) ;
@@ -24,9 +32,10 @@ const loginButton = document.getElementById("login");
2432loginButton . onclick = async ( e ) => {
2533 e . preventDefault ( ) ;
2634
27- // create an auth client
28- let authClient = await AuthClient . create ( ) ;
29-
35+ if ( authClient === undefined ) {
36+ console . error ( "AuthClient is not initialized yet." ) ;
37+ return false ;
38+ }
3039 // start the login process and wait for it to finish
3140 await new Promise ( ( resolve ) => {
3241 authClient . login ( {
You can’t perform that action at this time.
0 commit comments