Skip to content

Commit 0aa4222

Browse files
committed
feat: add options parameter to controller functions containing a query
1 parent 99ec86a commit 0aa4222

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/controllers/Auth.ts

Lines changed: 9 additions & 3 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,7 @@ 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, { queuable: false, timeout: -1, verb: "POST", ...options })
452453
.then((response) => {
453454
if (this.kuzzle.cookieAuthentication) {
454455
if (response.result.jwt) {
@@ -497,13 +498,14 @@ export class AuthController extends BaseController {
497498
*
498499
* @see https://docs.kuzzle.io/sdk/js/7/controllers/auth/logout
499500
*/
500-
async logout(): Promise<void> {
501+
async logout(options: ArgsAuthControllerLogin = {}): Promise<void> {
501502
this.kuzzle.emit("beforeLogout");
502503
try {
503504
await this.query(
504505
{
505506
action: "logout",
506507
cookieAuth: this.kuzzle.cookieAuthentication,
508+
...options
507509
},
508510
{ queuable: false, timeout: -1 }
509511
);
@@ -700,6 +702,10 @@ export type ArgsAuthControllerUpdateSelf = ArgsDefault;
700702

701703
export type ArgsAuthControllerValidateMyCredentials = ArgsDefault;
702704

705+
export type ArgsAuthControllerLogin = ArgsDefault;
706+
707+
export type ArgsAuthControllerLogout = ArgsDefault;
708+
703709
export interface ArgsAuthControllerRefreshToken extends ArgsDefault {
704710
expiresIn?: number | string;
705711
}

src/controllers/Security.ts

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

518-
refresh(collection) {
518+
refresh(collection, options: ArgsSecurityControllerRefresh = {}) {
519519
return this.query({
520520
action: "refresh",
521521
collection,
522-
});
522+
}, options);
523523
}
524524

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

811811
export type ArgsSecurityControllerValidateCredentials = ArgsDefault;
812+
813+
export type ArgsSecurityControllerRefresh = ArgsDefault;

0 commit comments

Comments
 (0)