Skip to content

Commit

Permalink
PREAPPS-7988: fixed change password
Browse files Browse the repository at this point in the history
  • Loading branch information
k-kato authored and silentsakky committed Nov 28, 2024
1 parent dfc4581 commit c981fea
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 15 deletions.
52 changes: 37 additions & 15 deletions src/batch-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,22 +530,44 @@ export class ZimbraBatchClient {
loginNewPassword,
password,
username,
dryRun = false
}: ChangePasswordOptions) =>
this.jsonRequest({
name: 'ChangePassword',
namespace: Namespace.Account,
body: {
account: {
by: 'name',
_content: username
dryRun = false,
authToken,
csrfToken
}: ChangePasswordOptions) => {
if (authToken) {
return this.jsonRequest({
name: 'ChangePassword',
namespace: Namespace.Account,
body: {
account: {
by: 'name',
_content: username
},
oldPassword: password,
password: loginNewPassword,
dryRun,
authToken: { _content: authToken },
csrfToken: { _content: csrfToken }
},
oldPassword: password,
password: loginNewPassword,
dryRun
},
singleRequest: true
});
singleRequest: true
});
} else {
return this.jsonRequest({
name: 'ChangePassword',
namespace: Namespace.Account,
body: {
account: {
by: 'name',
_content: username
},
oldPassword: password,
password: loginNewPassword,
dryRun
},
singleRequest: true
});
}
};

public checkCalendar = ({ id, value }: FolderActionCheckCalendarInput) =>
this.action(ActionType.folder, {
Expand Down
2 changes: 2 additions & 0 deletions src/batch-client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ export interface ShareInfoOptions {
}

export interface ChangePasswordOptions {
authToken: string;
csrfToken: string;
dryRun: boolean;
loginNewPassword: string;
password: string;
Expand Down
8 changes: 8 additions & 0 deletions src/schema/generated-schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export type AuthResponse = {
authToken?: Maybe<Array<Maybe<AuthToken>>>;
csrfToken?: Maybe<CsrfToken>;
lifetime?: Maybe<Scalars['Float']['output']>;
resetPassword?: Maybe<ResetPassword>;
session?: Maybe<Session>;
skin?: Maybe<Array<Maybe<Skin>>>;
trustedDevicesEnabled?: Maybe<TrustedDevicesEnabled>;
Expand Down Expand Up @@ -2802,6 +2803,8 @@ export type MutationChangeFolderColorArgs = {


export type MutationChangePasswordArgs = {
authToken?: InputMaybe<Scalars['String']['input']>;
csrfToken?: InputMaybe<Scalars['String']['input']>;
dryRun?: InputMaybe<Scalars['Boolean']['input']>;
loginNewPassword: Scalars['String']['input'];
password: Scalars['String']['input'];
Expand Down Expand Up @@ -4044,6 +4047,11 @@ export type ReplyActionInput = {
index?: InputMaybe<Scalars['Int']['input']>;
};

export type ResetPassword = {
__typename?: 'ResetPassword';
_content?: Maybe<Scalars['Boolean']['output']>;
};

export type ResetPasswordResponse = {
__typename?: 'ResetPasswordResponse';
attrs?: Maybe<ResetPasswordResponseAttributes>;
Expand Down
7 changes: 7 additions & 0 deletions src/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ type AuthResponse {
session: Session
skin: [Skin]
csrfToken: CsrfToken
resetPassword: ResetPassword
}

type ScratchCodeType {
Expand Down Expand Up @@ -388,6 +389,10 @@ type TrustedDevicesEnabled {
_content: Boolean
}

type ResetPassword {
_content: Boolean
}

type Session {
id: ID
_content: String
Expand Down Expand Up @@ -3684,6 +3689,8 @@ type Mutation {
loginNewPassword: String!
password: String!
username: String!
authToken: String
csrfToken: String
): AuthResponse
modifyProfileImage(
content: String
Expand Down

0 comments on commit c981fea

Please sign in to comment.