Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;