@inweb/client 25.6.2 → 25.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -1836,8 +1836,8 @@
1836
1836
  /**
1837
1837
  * Update job data on the server.
1838
1838
  *
1839
- * Only admins can update job data, if the current logged in user does not have administrator
1840
- * rights, an exception will be thrown.
1839
+ * Only administrators can update job data, if the current logged in user is not an
1840
+ * administrator, an exception will be thrown.
1841
1841
  *
1842
1842
  * @async
1843
1843
  * @param data - Raw job data.
@@ -3514,7 +3514,7 @@
3514
3514
  return this.data.initials;
3515
3515
  }
3516
3516
  /**
3517
- * `true` if user is has an administrator rights.
3517
+ * `true` if user is an administrator.
3518
3518
  */
3519
3519
  get isAdmin() {
3520
3520
  return this.data.isAdmin;
@@ -3584,8 +3584,8 @@
3584
3584
  /**
3585
3585
  * Refresh user data.
3586
3586
  *
3587
- * Only admins can checkout other users, if the current logged in user does not have
3588
- * administrator rights, hi can only checkout himself, otherwise an exception will be thrown.
3587
+ * Only administrators can checkout other users, if the current logged in user is not an
3588
+ * administrator, they can only checkout themselves, otherwise an exception will be thrown.
3589
3589
  */
3590
3590
  async checkout() {
3591
3591
  if (this.httpClient.signInUserIsAdmin) {
@@ -3606,8 +3606,8 @@
3606
3606
  /**
3607
3607
  * Update user data on the server.
3608
3608
  *
3609
- * Only admins can update other users, if the current logged in user does not have
3610
- * administrator rights, hi can only update himself, otherwise an exception will be thrown.
3609
+ * Only administrators can update other users, if the current logged in user is not an
3610
+ * administrator, they can only update themself, otherwise an exception will be thrown.
3611
3611
  *
3612
3612
  * @async
3613
3613
  * @param data - Raw user data.
@@ -3631,11 +3631,11 @@
3631
3631
  /**
3632
3632
  * Delete a user from the server.
3633
3633
  *
3634
- * Only admins can delete users, if the current logged in user does not have administrator
3635
- * rights, an exception will be thrown.
3634
+ * Only administrators can delete users, if the current logged in user is not an
3635
+ * administrator, an exception will be thrown.
3636
3636
  *
3637
- * Admins can delete themselves or other admins. An admin can only delete himself if he is
3638
- * not the last administrator.
3637
+ * Administrators can delete themselves or other administrators. An administrator can only
3638
+ * delete themself if they is not the last administrator.
3639
3639
  *
3640
3640
  * You need to re-login to continue working after deleting the current logged in user.
3641
3641
  *
@@ -3672,8 +3672,8 @@
3672
3672
  /**
3673
3673
  * Set or remove the user avatar.
3674
3674
  *
3675
- * Only admins can set the avatar of other users, if the current logged in user does not have
3676
- * administrator rights, he can only set his own avatar, otherwise an exception will be thrown.
3675
+ * Only administrators can set the avatar of other users, if the current logged in user is
3676
+ * not an administrator, they can only set their avatar, otherwise an exception will be thrown.
3677
3677
  *
3678
3678
  * @async
3679
3679
  * @param image - Avatar image. Can be a
@@ -3706,9 +3706,8 @@
3706
3706
  /**
3707
3707
  * Remove the user avatar.
3708
3708
  *
3709
- * Only admins can remove the avatar of other users, if the current logged in user does not
3710
- * have administrator rights, they can only remove their own avatar, otherwise an exception
3711
- * will be thrown.
3709
+ * Only administrators can remove the avatar of other users, if the current logged in user is
3710
+ * not an administrator, they can only remove their avatar, otherwise an exception will be thrown.
3712
3711
  *
3713
3712
  * @async
3714
3713
  */
@@ -3728,6 +3727,36 @@
3728
3727
  }
3729
3728
  return this;
3730
3729
  }
3730
+ /**
3731
+ * Change the user password.
3732
+ *
3733
+ * Only administrators can change the passwords of other users, if the current logged in user
3734
+ * is not an administrator, they can only change their password, otherwise an exception will
3735
+ * be thrown.
3736
+ *
3737
+ * To change their password, non-administrator users must provide their old password.
3738
+ *
3739
+ * @async
3740
+ * @param newPassword - New user password.
3741
+ * @param oldPassword - Old user password. Only required for non-administrator users to
3742
+ * change their password.
3743
+ */
3744
+ async changePassword(newPassword, oldPassword) {
3745
+ if (this.httpClient.signInUserIsAdmin) {
3746
+ const response = await this.httpClient.put(`/users/${this.id}/password`, { new: newPassword });
3747
+ const data = await response.json();
3748
+ this.data = { id: data.id, ...data.userBrief };
3749
+ }
3750
+ else if (this.id === this.httpClient.signInUserId) {
3751
+ const response = await this.httpClient.put("/user/password", { old: oldPassword, new: newPassword });
3752
+ const data = await response.json();
3753
+ this.data = { id: this.id, ...data };
3754
+ }
3755
+ else {
3756
+ return Promise.reject(new FetchError(403));
3757
+ }
3758
+ return this;
3759
+ }
3731
3760
  }
3732
3761
 
3733
3762
  ///////////////////////////////////////////////////////////////////////////////
@@ -3829,7 +3858,7 @@
3829
3858
  .then((data) => ({
3830
3859
  ...data,
3831
3860
  server: data.version,
3832
- client: "25.6.2",
3861
+ client: "25.6.3",
3833
3862
  }));
3834
3863
  }
3835
3864
  /**
@@ -3949,8 +3978,8 @@
3949
3978
  /**
3950
3979
  * Change server settings.
3951
3980
  *
3952
- * Only admins can change server settings, if the current logged in user does not have
3953
- * administrator rights, an exception will be thrown.
3981
+ * Only administrators can change server settings, if the current logged in user is not an
3982
+ * administrator, an exception will be thrown.
3954
3983
  *
3955
3984
  * @async
3956
3985
  */
@@ -3960,8 +3989,8 @@
3960
3989
  /**
3961
3990
  * Returns a list of server users.
3962
3991
  *
3963
- * Only admins can get a list of users, if the current logged in user does not have
3964
- * administrator rights, an exception will be thrown.
3992
+ * Only administrators can get a list of users, if the current logged in user is not an
3993
+ * administrator, an exception will be thrown.
3965
3994
  *
3966
3995
  * @async
3967
3996
  */
@@ -3975,8 +4004,8 @@
3975
4004
  /**
3976
4005
  * Returns the user information.
3977
4006
  *
3978
- * Only admins can get other users, if the current logged in user does not have administrator
3979
- * rights, hi can only get himself, otherwise an exception will be thrown.
4007
+ * Only administrators can get other users, if the currently logged in user is not an
4008
+ * administrator, they can only get themselves, otherwise an exception will be thrown.
3980
4009
  *
3981
4010
  * @async
3982
4011
  * @param userId - User ID.
@@ -4003,8 +4032,8 @@
4003
4032
  /**
4004
4033
  * Create a new user.
4005
4034
  *
4006
- * Only admins can create users, if the current logged in user does not have administrator
4007
- * rights, an exception will be thrown.
4035
+ * Only administrators can create users, if the current logged in user is not an
4036
+ * administrator, an exception will be thrown.
4008
4037
  *
4009
4038
  * @async
4010
4039
  * @param email - User email. Cannot be empty.
@@ -4039,11 +4068,11 @@
4039
4068
  /**
4040
4069
  * Delete a user from the server.
4041
4070
  *
4042
- * Only admins can delete users, if the current logged in user does not have administrator
4043
- * rights, an exception will be thrown.
4071
+ * Only administrators can delete users, if the current logged in user is not an
4072
+ * administrator, an exception will be thrown.
4044
4073
  *
4045
- * Admins can delete themselves or other admins. An admin can only delete himself if he is
4046
- * not the last administrator.
4074
+ * Administrators can delete themselves or other administrators. An administrator can only
4075
+ * delete themself if they is not the last administrator.
4047
4076
  *
4048
4077
  * You need to re-login to continue working after deleting the current logged in user.
4049
4078
  *
@@ -4554,7 +4583,7 @@
4554
4583
  }
4555
4584
 
4556
4585
  ///////////////////////////////////////////////////////////////////////////////
4557
- const version = "25.6.2";
4586
+ const version = "25.6.3";
4558
4587
 
4559
4588
  exports.Assembly = Assembly;
4560
4589
  exports.ClashTest = ClashTest;