Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh/ts/patch 025 service authentication authentication events #1927

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions service/authentication/AuthenticationEvents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ describe( "/service/authentication/AuthenticationEvents members", () => {
const {
IDENTITY_UPDATED,
AuthenticationEvents,
default: AuthenticationEventsDefault,
...others
} = exported as any; // TODO: remove cast after typescript conversion
} = exported;

it( "known members", () => {
expect( IDENTITY_UPDATED ).toBe( 'authentication.identity_updated' );
if ( AuthenticationEvents ) {
expect( AuthenticationEvents.IDENTITY_UPDATED ).toBe( 'authentication.identity_updated' );
}

expect( AuthenticationEvents ).toBeDefined();
expect( AuthenticationEvents.IDENTITY_UPDATED ).toBe( 'authentication.identity_updated' );

expect( AuthenticationEventsDefault ).toBeDefined();
expect( AuthenticationEventsDefault.IDENTITY_UPDATED ).toBe( 'authentication.identity_updated' );
} );

it( "unknown members", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const AuthenticationEvents = {
export enum AuthenticationEvents {
/**
* Event callback arguments:
* function(authenticationEnabled, userIdentity)
Expand All @@ -7,7 +7,12 @@ const AuthenticationEvents = {
* userIdentity - if user has been logged in then it contains user name. If
* contains 'null' or 'undefined' then user is not logged in.
*/
IDENTITY_UPDATED: 'authentication.identity_updated'
IDENTITY_UPDATED = 'authentication.identity_updated'
};

module.exports = AuthenticationEvents;
export const IDENTITY_UPDATED = AuthenticationEvents.IDENTITY_UPDATED;

// TODO: this was a pre-ES6 module using module.exports = AuthenticationEvents which doesn't translate well
garyhuntddn marked this conversation as resolved.
Show resolved Hide resolved
garyhuntddn marked this conversation as resolved.
Show resolved Hide resolved
// it is used in a number of places and should be updated to use the named export

export default AuthenticationEvents;
14 changes: 13 additions & 1 deletion types/auto/service/authentication/AuthenticationEvents.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
export const IDENTITY_UPDATED: string;
export declare enum AuthenticationEvents {
/**
* Event callback arguments:
* function(authenticationEnabled, userIdentity)
* authenticationEnabled - indicates whether authentication has been enabled
* in this session
* userIdentity - if user has been logged in then it contains user name. If
* contains 'null' or 'undefined' then user is not logged in.
*/
IDENTITY_UPDATED = "authentication.identity_updated"
}
export declare const IDENTITY_UPDATED = AuthenticationEvents.IDENTITY_UPDATED;
export default AuthenticationEvents;