Skip to content

Commit

Permalink
Merge pull request #753 from kuzzleio/KZLPRD-618-certaines-fonctions-…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
rolljee authored Nov 5, 2024
2 parents 0cd9d77 + a13d054 commit 35791f2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
18 changes: 14 additions & 4 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,12 @@ 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,
})
.then((response) => {
if (this.kuzzle.cookieAuthentication) {
if (response.result.jwt) {
Expand Down Expand Up @@ -497,15 +503,15 @@ 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,
},
{ queuable: false, timeout: -1 }
{ queuable: false, timeout: -1, ...options }
);
this._authenticationToken = null;
/**
Expand Down Expand Up @@ -700,6 +706,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;
}
15 changes: 10 additions & 5 deletions src/controllers/Security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,14 @@ export class SecurityController extends BaseController {
);
}

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

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

export type ArgsSecurityControllerValidateCredentials = ArgsDefault;

export type ArgsSecurityControllerRefresh = ArgsDefault;

0 comments on commit 35791f2

Please sign in to comment.