workos-ruby icon indicating copy to clipboard operation
workos-ruby copied to clipboard

Fix reset password response

Open vddgil opened this issue 1 month ago • 1 comments

Description

According to the documentation, the reset password response is supposed to return the user, But, in the gem, the user was nil because the user is wrapped in {"user": {...}} This fix extract the user from the wrapped value

vddgil avatar Nov 20 '25 08:11 vddgil

Greptile Overview

Greptile Summary

This PR re-implements the fix from PR #406 by manually parsing the JSON response to extract the user data from the wrapped {"user": {...}} format. The change is functionally correct and handles the API response properly, but uses a more verbose approach compared to the existing UserResponse class that was designed for this exact purpose.

Confidence Score: 5/5

  • This PR is safe to merge - the change correctly handles the wrapped API response
  • The implementation is functionally correct and properly extracts user data from the wrapped response format. While it could use the existing UserResponse abstraction for better code maintainability, the change doesn't introduce any bugs or security issues
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
lib/workos/user_management.rb 5/5 Replaced UserResponse.new(response.body).user with manual JSON parsing to extract user data from wrapped API response - functionally equivalent but uses a different implementation pattern

Sequence Diagram

sequenceDiagram
    participant Client
    participant UserManagement
    participant API as WorkOS API
    participant User as WorkOS::User

    Client->>UserManagement: reset_password(token, new_password)
    UserManagement->>API: POST /user_management/password_reset/confirm
    API-->>UserManagement: {"user": {id, email, ...}}
    UserManagement->>UserManagement: JSON.parse(response.body)
    UserManagement->>UserManagement: Extract parsed_response['user']
    UserManagement->>User: new(user_data.to_json)
    User-->>UserManagement: User object
    UserManagement-->>Client: User object

greptile-apps[bot] avatar Nov 20 '25 08:11 greptile-apps[bot]