Skip to content
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

zerver/views/users.py: Remove duplication and add func to validate user id. #9570

Closed
wants to merge 1 commit into from

Conversation

YJDave
Copy link
Collaborator

@YJDave YJDave commented May 28, 2018

Followup of #9449

Add function access_user_by_id to access user_id within same realm.

Testing Plan:

GIFs or Screenshots:

bot = get_user_profile_by_id_in_realm(bot_id, user_profile.realm)
except UserProfile.DoesNotExist:
return json_error(_('No such user'))
bot = access_user_by_id(user_profile, bot_id)
Copy link
Sponsor Member

@timabbott timabbott May 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of these functions should be calling an access_bot_by_id, that does the "not a bot" and can_admin_user checks as well.

And the access_* methods should go in zerver/lib/users.py.

…ate bot id.

Add function `access_bot_by_id` to access bot id within same realm.
@YJDave
Copy link
Collaborator Author

YJDave commented May 29, 2018

@timabbott Thanks for reviewing! Updated.

@timabbott
Copy link
Sponsor Member

Nice, I cleaned up the commit message and merged, thanks @YJDave!

As a follow-up, should we make a version for getting a human user (looks like we have 3 calls points for that too)? We'll probably want a flag for whether inactive users are allowed/required (for reactivate_user_backend)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants