Skip to content

Commit

Permalink
updating with mainnet details
Browse files Browse the repository at this point in the history
  • Loading branch information
krpeacock committed May 11, 2021
1 parent cc37dcf commit 44ccb4b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# auth_demo
# Auth-Client Demo

Welcome to your new auth_demo project and to the internet computer development community. By default, creating a new project adds this README and some template files to your project directory. You can edit these template files to customize your project and to include your own code to speed up the development cycle.
This is an example project, intended to demonstrate how an app developer might integrate with an [Internet Identity](https://identity.ic0.app).

[Live demo](https://hpgtk-2qaaa-aaaab-qaapq-cai.raw.ic0.app/)

This is an example showing how to use [@dfinity/auth-client](https://www.npmjs.com/package/@dfinity/auth-client).

To get started, you might want to explore the project directory structure and the default configuration file. Working with this project in your development environment will not affect any production deployment or identity tokens.

Expand Down
8 changes: 8 additions & 0 deletions canister_ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"whoami": {
"ic": "hihv6-xiaaa-aaaab-qaapa-cai"
},
"www": {
"ic": "hpgtk-2qaaa-aaaab-qaapq-cai"
}
}
1 change: 0 additions & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"packtool": ""
}
},
"dfx": "0.7.0-beta.6",
"networks": {
"local": {
"bind": "127.0.0.1:8000",
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async function handleAuthenticated(authClient: AuthClient) {
const identity = await authClient.getIdentity();

const agent = new HttpAgent({ identity });
console.log(process.env.CANISTER_ID);
const whoami_actor = Actor.createActor<_SERVICE>(idlFactory, {
agent,
canisterId: process.env.CANISTER_ID as string,
Expand Down
30 changes: 16 additions & 14 deletions src/frontend/src/views/loggedIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ export const renderLoggedIn = (
) => {
render(content(), document.getElementById("pageContent") as HTMLElement);

(document.getElementById(
"whoamiButton"
) as HTMLButtonElement).onclick = async () => {
const response = await actor.whoami();
(document.getElementById(
"whoami"
) as HTMLElement).innerText = response.toString();
};
(document.getElementById("whoamiButton") as HTMLButtonElement).onclick =
async () => {
try {
const response = await actor.whoami();
console.log(response);
(document.getElementById("whoami") as HTMLInputElement).value =
response.toString();
} catch (error) {
console.error(error);
}
};

(document.getElementById(
"logout"
) as HTMLButtonElement).onclick = async () => {
await authClient.logout();
renderIndex();
};
(document.getElementById("logout") as HTMLButtonElement).onclick =
async () => {
await authClient.logout();
renderIndex();
};
};

0 comments on commit 44ccb4b

Please sign in to comment.