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

feat: admin permissions required to view profile details #72

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions api/messages/messages_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,22 @@ def get_profile_metadata_old(propel_id):

return Message(response)


def get_all_profiles():
db = get_db()
docs = db.collection('users').stream() # steam() gets all records
if docs is None:
return {[]}
else:
results = []
for doc in docs:
results.append(doc_to_json(docid=doc.id, doc=doc))

# log result
logger.info(results)
return { "profiles": results }


# Caching is not needed because the parent method already is caching
@limits(calls=100, period=ONE_MINUTE)
def get_history_old(db_id):
Expand Down
16 changes: 15 additions & 1 deletion api/messages/messages_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
link_problem_statements_to_events_old,
save_news,
save_lead_async,
get_news
get_news,
get_all_profiles
)


Expand Down Expand Up @@ -273,3 +274,16 @@ def save_profile():
def get_profile_by_id(id):
return get_user_by_id_old(id)


def getOrgId(req):
# Ref: https://docs.propelauth.com/reference/backend-apis/flask#req-to-org-id
return "77f70865-7da9-4588-850b-a5ebb6974410" # PropelAuth wants you to pass this in as a req param, but let's keep it simple


# Used to provide profile details - user must be logged in
@bp.route("/admin/profiles", methods=["GET"])
@auth.require_org_member_with_permission("profile.admin", req_to_org_id=getOrgId)
def all_profiles():
return get_all_profiles()


Loading