Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust to new set_password APIs #31

Merged
merged 6 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,18 @@ end

#### Set or Expire User Password

You can set or expire a user's password.
Note: When setting a password, it will automatically be set as expired.
You can set (temporary/active) or expire a user's password.
Note: When using SetTemporaryPassword password will automatically be set as expired.
The user will not be able log-in using an expired password, and will be required replace it on next login.

```ruby
# Set a user's temporary password
descope_client.set_temporary_password(login_id: '<login-id>', password: '<some-password>');

# Set a user's password
descope_client.set_active_password(login_id: '<login-id>', password: '<some-password>');

# DEPRECATED
# Set a user's password
descope_client.set_password(login_id: '<login-id>', password: '<some-password>');

Expand Down
4 changes: 3 additions & 1 deletion lib/descope/api/v1/management/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ module Common
USER_UPDATE_CUSTOM_ATTRIBUTE_PATH = '/v1/mgmt/user/update/customAttribute'
USER_ADD_ROLE_PATH = '/v1/mgmt/user/update/role/add'
USER_REMOVE_ROLE_PATH = '/v1/mgmt/user/update/role/remove'
USER_SET_PASSWORD_PATH = '/v1/mgmt/user/password/set'
USER_SET_TEMPORARY_PASSWORD_PATH = '/v1/mgmt/user/password/set/temporary'
USER_SET_ACTIVE_PASSWORD_PATH = '/v1/mgmt/user/password/set/active'
USER_SET_PASSWORD_PATH = '/v1/mgmt/user/password/set'
USER_EXPIRE_PASSWORD_PATH = '/v1/mgmt/user/password/expire'
USER_ADD_TENANT_PATH = '/v1/mgmt/user/update/tenant/add'
USER_REMOVE_TENANT_PATH = '/v1/mgmt/user/update/tenant/remove'
Expand Down
17 changes: 17 additions & 0 deletions lib/descope/api/v1/management/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,23 @@ def user_remove_tenant_roles(login_id: nil, tenant_id: nil, role_names: [])
post(Common::USER_REMOVE_TENANT_PATH, body)
end

def set_temporary_password(login_id: nil, password: nil)
guyp-descope marked this conversation as resolved.
Show resolved Hide resolved
body = {
loginId: login_id,
password:
}
post(Common::USER_SET_TEMPORARY_PASSWORD_PATH, body)
end

def set_active_password(login_id: nil, password: nil)
guyp-descope marked this conversation as resolved.
Show resolved Hide resolved
body = {
loginId: login_id,
password:
}
post(Common::USER_SET_ACTIVE_PASSWORD_PATH, body)
end

# Deprecated (use set_temporary_password(..) instead)
def set_password(login_id: nil, password: nil)
body = {
loginId: login_id,
Expand Down