-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from citysciencelab/sharing-users-interface
Introduce more interfaces for sharing functionality
- Loading branch information
Showing
4 changed files
with
60 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
"""Endpoints to access user information via keycloak""" | ||
|
||
import json | ||
|
||
from apiflask import APIBlueprint | ||
from flask import Response, g | ||
|
||
from ump.api.keycloak_utils import get_user_name | ||
from ump.api.keycloak_utils import get_gravatar_url, get_user_name | ||
|
||
users = APIBlueprint("users", __name__) | ||
|
||
@users.route("/<path:user_id>/name") | ||
|
||
@users.route("/<path:user_id>/details", methods=["GET"]) | ||
def index(user_id=None): | ||
"Retrieve user name by user id" | ||
auth = g.get("auth_token") | ||
if auth is None: | ||
return Response(mimetype="application/json", status=401) | ||
|
||
user_name = get_user_name(user_id) | ||
gravatar_url = get_gravatar_url(user_id) | ||
|
||
response_data = { | ||
"user_id": user_id, | ||
"username": user_name, | ||
"gravatar_url": gravatar_url, | ||
} | ||
|
||
return Response(json.dumps(response_data), mimetype="application/json") |