Skip to content

Commit 35791f2

Browse files
authored
Merge pull request #753 from kuzzleio/KZLPRD-618-certaines-fonctions-nont-pas-encore-acces-a-un-param-option-ce-qui-empeche-dutiliser-loption-allow-trigger-events
feat: add options parameter to controller functions containing a query
2 parents 0cd9d77 + a13d054 commit 35791f2

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/controllers/Auth.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ export class AuthController extends BaseController {
437437
login(
438438
strategy: string,
439439
credentials: JSONObject,
440-
expiresIn?: string | number
440+
expiresIn?: string | number,
441+
options: ArgsAuthControllerLogin = {}
441442
): Promise<string> {
442443
const request = {
443444
action: "login",
@@ -448,7 +449,12 @@ export class AuthController extends BaseController {
448449
};
449450

450451
this.kuzzle.emit("beforeLogin");
451-
return this.query(request, { queuable: false, timeout: -1, verb: "POST" })
452+
return this.query(request, {
453+
queuable: false,
454+
timeout: -1,
455+
verb: "POST",
456+
...options,
457+
})
452458
.then((response) => {
453459
if (this.kuzzle.cookieAuthentication) {
454460
if (response.result.jwt) {
@@ -497,15 +503,15 @@ export class AuthController extends BaseController {
497503
*
498504
* @see https://docs.kuzzle.io/sdk/js/7/controllers/auth/logout
499505
*/
500-
async logout(): Promise<void> {
506+
async logout(options: ArgsAuthControllerLogin = {}): Promise<void> {
501507
this.kuzzle.emit("beforeLogout");
502508
try {
503509
await this.query(
504510
{
505511
action: "logout",
506512
cookieAuth: this.kuzzle.cookieAuthentication,
507513
},
508-
{ queuable: false, timeout: -1 }
514+
{ queuable: false, timeout: -1, ...options }
509515
);
510516
this._authenticationToken = null;
511517
/**
@@ -700,6 +706,10 @@ export type ArgsAuthControllerUpdateSelf = ArgsDefault;
700706

701707
export type ArgsAuthControllerValidateMyCredentials = ArgsDefault;
702708

709+
export type ArgsAuthControllerLogin = ArgsDefault;
710+
711+
export type ArgsAuthControllerLogout = ArgsDefault;
712+
703713
export interface ArgsAuthControllerRefreshToken extends ArgsDefault {
704714
expiresIn?: number | string;
705715
}

src/controllers/Security.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,14 @@ export class SecurityController extends BaseController {
515515
);
516516
}
517517

518-
refresh(collection) {
519-
return this.query({
520-
action: "refresh",
521-
collection,
522-
});
518+
refresh(collection, options: ArgsSecurityControllerRefresh = {}) {
519+
return this.query(
520+
{
521+
action: "refresh",
522+
collection,
523+
},
524+
options
525+
);
523526
}
524527

525528
replaceUser(_id, body, options: ArgsSecurityControllerReplaceUser = {}) {
@@ -809,3 +812,5 @@ export type ArgsSecurityControllerUpdateUser = ArgsDefault;
809812
export type ArgsSecurityControllerUpdateUserMapping = ArgsDefault;
810813

811814
export type ArgsSecurityControllerValidateCredentials = ArgsDefault;
815+
816+
export type ArgsSecurityControllerRefresh = ArgsDefault;

0 commit comments

Comments
 (0)