Skip to content

Commit

Permalink
test: add allowed principal setter and getter in target canister
Browse files Browse the repository at this point in the history
  • Loading branch information
Web3NL committed Oct 9, 2023
1 parent 7b4cd13 commit a6e4c05
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tools/ui/target_test_canister/main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -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");
};

Expand Down

0 comments on commit a6e4c05

Please sign in to comment.