Skip to content

Commit

Permalink
Updated the sign in js action to support authentication token.
Browse files Browse the repository at this point in the history
  • Loading branch information
EnasAbdelrazek committed Jul 1, 2024
1 parent d63c590 commit caafd2b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/jsActions/nanoflow-actions-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

- We've added support for the token-based authentication with the SignIn action. This authentication method allows users to remain signed in until the expiration time of the token. You can read more about this behavior on this documentation page https://docs.mendix.com/refguide/session-management/#2-authentication-token

To enable it you can set the new SignIn action parameter `useAuthToken` to `true`.

## [4.0.3] Nanoflow Commons - 2024-3-19
### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import { Big } from "big.js";
*
* @param {string} username - This field is required.
* @param {string} password - This field is required.
* @param {boolean} useAuthToken - This field is optional.
* @returns {Promise.<Big>}
*/
export async function SignIn(username?: string, password?: string): Promise<Big> {
export async function SignIn(username?: string, password?: string, useAuthToken?: boolean): Promise<Big> {
// BEGIN USER CODE
if (!username || !password) {
return Promise.resolve(new Big(401));
Expand All @@ -32,7 +33,11 @@ export async function SignIn(username?: string, password?: string): Promise<Big>
const onSuccess = (): void => resolve(new Big(200));
const onError = (error: { status: number }): void => resolve(new Big(error.status));

mx.login(username, password, onSuccess, onError as any);
if (typeof useAuthToken === "undefined") {
mx.login(username, password, onSuccess, onError as any);
} else {
mx.login2(username, password, Boolean(useAuthToken), onSuccess, onError as any);
}
});
// END USER CODE
}
7 changes: 7 additions & 0 deletions packages/jsActions/nanoflow-actions-native/typings/mx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@ declare namespace mx {
}
interface MxInterface {
reload: () => void;
login2(
username: string,
password: string,
useAuthToken: boolean,
onSuccess: () => void,
onError: () => void
): void;
}
}

0 comments on commit caafd2b

Please sign in to comment.