Skip to content

Commit

Permalink
[ADD] Sveltekit whoami support
Browse files Browse the repository at this point in the history
  • Loading branch information
whikernel committed Dec 5, 2024
1 parent 56e82af commit 9538058
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion source/app/blueprints/rest/v2/auth/api_v2_auth_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from app.blueprints.rest.endpoints import response_api_success
from app.business.auth import validate_ldap_login, validate_local_login
from app.iris_engine.utils.tracker import track_activity
from app.schema.marshables import UserSchema

api_v2_auth_blueprint = Blueprint('auth_rest_v2',
__name__,
Expand Down Expand Up @@ -91,4 +92,20 @@ def logout():
logout_user()
session.clear()

return redirect(not_authenticated_redirection_url('/'))
return redirect(not_authenticated_redirection_url('/'))


@api_v2_auth_blueprint.route('/auth/whoami', methods=['GET'])
def whoami():
"""
Returns information about the currently authenticated user.
"""

# Ensure we are authenticated
if not current_user.is_authenticated:
return response_api_error("Unauthenticated")

# Return the current_user dict
return response_api_success(data=UserSchema(only=[
'id', 'user_name', 'user_login', 'user_email'
]).dump(current_user))

0 comments on commit 9538058

Please sign in to comment.