Hi, in my code, i am overriding the consume_code_...
# support-questions-legacy
n
Hi, in my code, i am overriding the consume_code_post, if created_new_user then i am assigning some roles to that user before sending consume_code_post api response. But in frontend if they do "await Session.getClaimValue({claim: UserRoleClaim});" they are getting []. If they logout and login again then they are getting ["role_name"].Basically this is happening only for signup
r
Hey. You need to assign roles to the user in the function override for consume code. Not api override. See our docs for post sign in up callback. It uses the functions override.
n
def override_passwordless_apis(original_implementation: APIInterface): original_consume_code_post = original_implementation.consume_code_post async def consume_code_post(pre_auth_session_id: str, user_input_code: Union[str, None], device_id: Union[str, None], link_code: Union[str, None], api_options: APIOptions, user_context: Dict[str, Any]): response = await original_consume_code_post(pre_auth_session_id, user_input_code, device_id, link_code, api_options, user_context) # Post sign up response, we check if it was successful if isinstance(response, ConsumeCodePostOkResult): _ = response.user.user_id __ = response.user.email _ = response.user.phone_number if response.created_new_user: res = await add_role_to_user("public",response.user.user_id, "role_name") return response original_implementation.consume_code_post = consume_code_post return original_implementation
I have implemented this from your document only
r
if you see this, https://supertokens.com/docs/passwordless/common-customizations/handling-signinup-success, it shows you that you need to override the functions and not the apis
5 Views