Conversation
There was a problem hiding this comment.
Pull request overview
Updates the User model decoding to better interoperate with OIDC-style userinfo responses (e.g., sub/picture) and adds a small repo hygiene tweak.
Changes:
- Add custom
Codableimplementation forUserto acceptidorsub, andimageorpicture. - Minor
Package.swiftmanifest formatting adjustments. - Ignore
.envfiles via.gitignore.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Sources/RxAuthSwift/AuthenticationState.swift | Adds custom User decoding/encoding to support alternate JSON field names (sub, picture). |
| Package.swift | Removes trailing commas / normalizes manifest formatting in dependency lists. |
| .gitignore | Adds .env to ignored files to avoid committing local environment secrets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.email = try container.decodeIfPresent(String.self, forKey: .email) | ||
| // Support both "image" and "picture" (OIDC standard) for profile image | ||
| self.image = try container.decodeIfPresent(String.self, forKey: .image) | ||
| ?? container.decodeIfPresent(String.self, forKey: .picture) |
There was a problem hiding this comment.
This won’t compile: the second decodeIfPresent call in the nil-coalescing expression is also throwing, but it isn’t prefixed with try (Swift requires try for each throwing call, or try applied to the whole expression). Add try (or restructure) so both decode attempts are handled correctly.
| ?? container.decodeIfPresent(String.self, forKey: .picture) | |
| ?? try container.decodeIfPresent(String.self, forKey: .picture) |
| // Support both "id" and "sub" (OIDC standard) for user identifier | ||
| if let id = try container.decodeIfPresent(String.self, forKey: .id) { | ||
| self.id = id | ||
| } else if let sub = try container.decodeIfPresent(String.self, forKey: .sub) { | ||
| self.id = sub |
There was a problem hiding this comment.
New decoding behavior supports sub and picture, but current tests only cover round-tripping id and image. Add unit tests that decode JSON payloads containing only sub (no id) and only picture (no image) to ensure this compatibility stays working.
No description provided.