feat: add user password/status/invite commands and fix zero-value timestamps on user create/update#34
Merged
Merged
Conversation
…estamps Add OneLogin user management commands that complete user creation and invitation flows: - user set-password: set an existing user's password - user set-status: change a user's status (1/2/4/5) - user send-invite: send a password setup/reset invite link via email Each command follows a single responsibility. CreateUser now only creates the user and returns its ID (the SetUserState side effect was removed), and set-status sends only the status field. Also fix a bug where zero-value time.Time fields were written to OneLogin. models.User declares timestamps as non-pointer time.Time, so omitempty could not drop them and they were sent as "0001-01-01T00:00:00Z", corrupting server-managed values such as "Last login". CreateUser/UpdateUser now strip zero-value time fields from the payload (onelogin/wrapper.go userPayload). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
modernizeリンターの指摘に対応。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
手元で実行、以下成功するのを確認済 |
buty4649
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
以下対応をしました。
追加コマンド
user set-password --email <EMAIL> --password <PW>user set-status --email <EMAIL> --status <N>user send-invite --email <EMAIL> [--personal-email <EMAIL>]status 4(PasswordExpired)を設定すると、初回ログイン時にパスワード変更が要求されます。バグ修正: ゼロ値の時刻が書き込まれる問題
SDK の
models.Userは時刻フィールドを非ポインタtime.Timeで持つためomitemptyが効かず、未設定の時刻が0001-01-01T00:00:00Zとしてリクエストに含まれていました。この結果、ユーザー作成後に OneLogin 側の "Last login" 等の時刻が不正な過去日付になっていました。CreateUser/UpdateUserのペイロードからゼロ値の時刻フィールドを除去するよう修正しました(onelogin/wrapper.goのuserPayload)。リファクタ
CreateUserは作成のみを行い、作成したユーザー ID を返すよう変更(副作用だったSetUserStateを削除)set-statusは status のみを送信し、他フィールドのゼロ値上書きを回避