Skip to content

Commit

Permalink
feat: add options parameter to controller functions containing a query
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrng committed Oct 16, 2024
1 parent 99ec86a commit 0aa4222
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/controllers/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ export class AuthController extends BaseController {
login(
strategy: string,
credentials: JSONObject,
expiresIn?: string | number
expiresIn?: string | number,
options: ArgsAuthControllerLogin = {}
): Promise<string> {
const request = {
action: "login",
Expand All @@ -448,7 +449,7 @@ export class AuthController extends BaseController {
};

this.kuzzle.emit("beforeLogin");
return this.query(request, { queuable: false, timeout: -1, verb: "POST" })
return this.query(request, { queuable: false, timeout: -1, verb: "POST", ...options })

Check failure on line 452 in src/controllers/Auth.ts

View workflow job for this annotation

GitHub Actions / Lint (18)

Replace `·queuable:·false,·timeout:·-1,·verb:·"POST",·...options` with `⏎······queuable:·false,⏎······timeout:·-1,⏎······verb:·"POST",⏎······...options,⏎···`
.then((response) => {
if (this.kuzzle.cookieAuthentication) {
if (response.result.jwt) {
Expand Down Expand Up @@ -497,13 +498,14 @@ export class AuthController extends BaseController {
*
* @see https://docs.kuzzle.io/sdk/js/7/controllers/auth/logout
*/
async logout(): Promise<void> {
async logout(options: ArgsAuthControllerLogin = {}): Promise<void> {
this.kuzzle.emit("beforeLogout");
try {
await this.query(
{
action: "logout",
cookieAuth: this.kuzzle.cookieAuthentication,
...options

Check failure on line 508 in src/controllers/Auth.ts

View workflow job for this annotation

GitHub Actions / Lint (18)

Insert `,`
},
{ queuable: false, timeout: -1 }
);
Expand Down Expand Up @@ -700,6 +702,10 @@ export type ArgsAuthControllerUpdateSelf = ArgsDefault;

export type ArgsAuthControllerValidateMyCredentials = ArgsDefault;

export type ArgsAuthControllerLogin = ArgsDefault;

export type ArgsAuthControllerLogout = ArgsDefault;

export interface ArgsAuthControllerRefreshToken extends ArgsDefault {
expiresIn?: number | string;
}
6 changes: 4 additions & 2 deletions src/controllers/Security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ export class SecurityController extends BaseController {
);
}

refresh(collection) {
refresh(collection, options: ArgsSecurityControllerRefresh = {}) {
return this.query({

Check failure on line 519 in src/controllers/Security.ts

View workflow job for this annotation

GitHub Actions / Lint (18)

Insert `⏎······`
action: "refresh",

Check failure on line 520 in src/controllers/Security.ts

View workflow job for this annotation

GitHub Actions / Lint (18)

Insert `··`
collection,

Check failure on line 521 in src/controllers/Security.ts

View workflow job for this annotation

GitHub Actions / Lint (18)

Insert `··`
});
}, options);

Check failure on line 522 in src/controllers/Security.ts

View workflow job for this annotation

GitHub Actions / Lint (18)

Replace `····},·options` with `······},⏎······options⏎····`
}

replaceUser(_id, body, options: ArgsSecurityControllerReplaceUser = {}) {
Expand Down Expand Up @@ -809,3 +809,5 @@ export type ArgsSecurityControllerUpdateUser = ArgsDefault;
export type ArgsSecurityControllerUpdateUserMapping = ArgsDefault;

export type ArgsSecurityControllerValidateCredentials = ArgsDefault;

export type ArgsSecurityControllerRefresh = ArgsDefault;

0 comments on commit 0aa4222

Please sign in to comment.