From a6e4c05e68b185f75c0a0dcfd4816f97d2b98c75 Mon Sep 17 00:00:00 2001 From: Web3NL Date: Mon, 9 Oct 2023 21:35:03 +0200 Subject: [PATCH] test: add allowed principal setter and getter in target canister --- tools/ui/target_test_canister/main.mo | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/ui/target_test_canister/main.mo b/tools/ui/target_test_canister/main.mo index b881cc6d..ffc50b41 100644 --- a/tools/ui/target_test_canister/main.mo +++ b/tools/ui/target_test_canister/main.mo @@ -4,10 +4,18 @@ import Text "mo:base/Text"; import Blob "mo:base/Blob"; actor { - let owner = Principal.fromText("oigup-gpnce-ytl3m-gkuwt-hf4yc-lci5d-ijsy5-oc4ak-kz3v2-fjbl5-mae"); + var allowed = Principal.fromText("oigup-gpnce-ytl3m-gkuwt-hf4yc-lci5d-ijsy5-oc4ak-kz3v2-fjbl5-mae"); + + public func _set_allowed_principal(principal: Text) : async () { + allowed := Principal.fromText(principal); + }; + + public query func _get_allowed_principal() : async Text { + Principal.toText(allowed); + }; public shared query ({ caller }) func hello() : async Text { - if (caller != owner) { + if (caller != allowed) { throw Error.reject("Unauthorized"); };