Skip to content
Snippets Groups Projects
Commit f5925f54 authored by Arie Peterson's avatar Arie Peterson
Browse files

Record registration method in kratos metadata

parent 2882ece1
No related branches found
No related tags found
1 merge request!161Resolve "Support Stackspin OIDC federation"
Pipeline #50125 passed with stages
in 3 minutes and 36 seconds
......@@ -254,7 +254,7 @@ class UserService:
kratos_identity_api.patch_identity(userID, json_patch=[patch])
@staticmethod
def after_user_registration(userID):
def after_user_registration(userID, registration_method):
dashboard_app = App.query.filter_by(slug="dashboard").first()
existing_app_role = AppRole.query.filter_by(app_id=dashboard_app.id, user_id=userID).first()
if existing_app_role is not None:
......@@ -268,6 +268,9 @@ class UserService:
)
db.session.add(app_role)
db.session.commit()
current_app.logger.info(f"Set registration_method for {userID} to {registration_method}")
patch = JsonPatch(op="replace", path="/metadata_admin/registration_method", value=registration_method)
kratos_identity_api.patch_identity(userID, json_patch=[patch])
@staticmethod
def __insertAppRoleToUser(userId, userRes):
......
......@@ -91,7 +91,7 @@ def after_registration():
data = request.get_json()
current_app.logger.warn(f"\"after registration\" webhook called with user id {data['user_id']}")
current_app.logger.warn(f"full webhook request: {data}")
UserService.after_user_registration(data["user_id"])
UserService.after_user_registration(data["user_id"], data["registration_method"])
return jsonify(message="Performed post-registration tasks.")
@api_v1.route("/users", methods=["POST"])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment