Skip to content

feat: add user password/status/invite commands and fix zero-value timestamps on user create/update#34

Merged
buty4649 merged 2 commits into
mainfrom
feat/user-send-invite
Jun 17, 2026
Merged

feat: add user password/status/invite commands and fix zero-value timestamps on user create/update#34
buty4649 merged 2 commits into
mainfrom
feat/user-send-invite

Conversation

@k-inatchi

@k-inatchi k-inatchi commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

概要

以下対応をしました。

  • OneLogin ユーザーの作成・招待まわりを onecli で完結できるよう、ユーザー管理コマンドを追加
  • ユーザー作成・更新時にゼロ値の時刻が OneLogin へ書き込まれてしまう不具合を修正

追加コマンド

コマンド 内容
user set-password --email <EMAIL> --password <PW> 既存ユーザーのパスワードを設定
user set-status --email <EMAIL> --status <N> ステータス変更(1=Active, 2=Suspended, 4=PasswordExpired, 5=AwaitingPasswordReset)
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.gouserPayload)。

リファクタ

  • CreateUser は作成のみを行い、作成したユーザー ID を返すよう変更(副作用だった SetUserState を削除)
  • set-status は status のみを送信し、他フィールドのゼロ値上書きを回避

k-inatchi and others added 2 commits June 17, 2026 16:23
…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>
@k-inatchi

k-inatchi commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

手元で実行、以下成功するのを確認済

op run --env-file=/tmp/onelogin.env -- sh -c '
  /tmp/onecli user add onecli_test inatchi test@inatchi.dev && \
  /tmp/onecli user set-password --email test@inatchi.dev --password "'"$PW"'" && \
  /tmp/onecli user set-status --email test@inatchi.dev --status 4 && \
  /tmp/onecli user send-invite --email test@inatchi.dev

Successfully added user: onecli_test inatchi with email: test@inatchi.dev
Successfully set password for test@inatchi.dev
Successfully set status 4 for test@inatchi.dev
Successfully sent invite link for test@inatchi.dev

@k-inatchi k-inatchi requested a review from buty4649 June 17, 2026 07:37
@buty4649 buty4649 merged commit 4b4d46e into main Jun 17, 2026
2 checks passed
@buty4649 buty4649 deleted the feat/user-send-invite branch June 17, 2026 07:51
@pepabo-pr-maker pepabo-pr-maker Bot mentioned this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants