-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
auth: miscellaneous #160
auth: miscellaneous #160
Conversation
src/auth.rs
Outdated
let principal = PrincipalStorable(principal); | ||
let mut auth_set = auth_map.get(&principal).unwrap_or_default(); | ||
let changed = auth_set.authorize(auth); | ||
auth_map.insert(principal, auth_set); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This insert
does nothing really if changed = false
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct; updated the code for clarity.
PROVIDERS.with(|providers| { | ||
let mut providers = providers.borrow_mut(); | ||
match providers.get(&args.provider_id) { | ||
Some(mut provider) => { | ||
if provider.owner != caller { | ||
if !(provider.owner == caller || is_controller) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trap
message needs to be updated. Shouldn't it simply be "You are not authorized" as above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right; thanks. Trying to do too many things at the same time, haha. Updated with additional text to distinguish cases where the owner has authorization.
do_authorize
anddo_deauthorize