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

Added new event dispatch key to identify auth type #11

Open
wants to merge 3 commits into
base: main
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"license": "AGPL-3.0-only",
"author": "Internet Archive",
"version": "0.2.4",
"version": "0.2.6",
"main": "dist/index.js",
"module": "dist/index.js",
"scripts": {
Expand Down
60 changes: 33 additions & 27 deletions src/ia-account-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ export class IAAccountSettings
/**
* contain profile picture URL
*
* @type {String}
* @type {string}
* @memberof IAUXAccountSettings
*/
@property({ type: String }) profilePicture: String = '';
@property({ type: String }) profilePicture: string = '';

/**
* contain boolean status loan history visibility
*
* @type {String | Boolean}
* @type {string | boolean}
* @memberof IAUXAccountSettings
*/
@property({ type: String }) loanHistoryFlag: String | Boolean = '';
@property({ type: String }) loanHistoryFlag: string | boolean = '';

/**
* contain profile csrf token
*
* @type {String}
* @type {string}
* @memberof IAUXAccountSettings
*/
@property({ type: String }) csrfToken: String = '';
@property({ type: String }) csrfToken: string = '';

/**
* contain fileSelect input field
Expand All @@ -107,7 +107,6 @@ export class IAAccountSettings
/**
* contains error data for form fields
*
* @private
* @type {ErrorModel}
* @memberof IAUXAccountSettings
*/
Expand All @@ -117,75 +116,81 @@ export class IAAccountSettings
* open delete form
*
* @private
* @type {Boolean}
* @type {boolean}
* @memberof IAUXAccountSettings
*/
@state() private attemptToDelete?: Boolean;
@state() private attemptToDelete?: boolean;

/**
* enable delete button when you make sure
*
* @private
* @type {Boolean}
* @type {boolean}
* @memberof IAUXAccountSettings
*/
@state() private confirmDelete?: Boolean = false;
@state() private confirmDelete: boolean = false;

/**
* object that contains updated fields data/text
*
* @private
* @type {Object}
* @type {ResponseModel}
* @memberof IAAccountSettings
*/
@state() private responseFields?: ResponseModel = {};
@state() private responseFields: ResponseModel = {};

/**
* determine if need to disable save button
*
* @private
* @type {Boolean}
* @type {boolean}
* @memberof IAAccountSettings
*/
@state() saveButtonDisabled?: Boolean = true;
@state() saveButtonDisabled: boolean = true;

/**
* determine if want to show authenticate page
*
* @type {Boolean}
* @type {boolean}
* @memberof IAUXAccountSettings
*/
@state() lookingToAuth?: Boolean = true;
@state() lookingToAuth: boolean = true;

/**
* determine if need to show loading indicator on buttons
*
* @type {Boolean}
* @type {boolean}
* @memberof IAUXAccountSettings
*/
@state() showLoadingIndicator?: Boolean;
@state() showLoadingIndicator?: boolean;

/**
* set true if want to make header sticky
*
* @type {Boolean}
* @type {boolean}
* @memberof IAUXAccountSettings
*/
@state() isStickyHeader?: Boolean = false;
@state() isStickyHeader: boolean = false;

/**
* toggle password field type to text|password
* @type {Boolean}
* @type {boolean}
* @memberof IAUXAccountSettings
*/
@state() private showPassword?: Boolean = false;
@state() private showPassword: boolean = false;

/**
* flag to verify if API has executed
* @type {Boolean}
* @type {boolean}
* @memberof IAUXAccountSettings
*/
@state() private apiHasExecuted: boolean = false;

/**
* Stores the authentication method used (e.g. 'ia' for Internet Archive)
* @type {string}
* @memberof IAUXAccountSettings
*/
@state() private apiHasExecuted?: Boolean = false;
@state() private authBy: 'ia' | 'google' | '' = '';

/**
* since we moved pic upload feature in separate component,
Expand Down Expand Up @@ -563,7 +568,7 @@ export class IAAccountSettings
log(`${provider} provider should be unlinked!`);
document.dispatchEvent(
new CustomEvent('IAThirdPartyAuth:unlinkProvider', {
detail: { provider },
detail: { provider, authBy: this.authBy },
})
);

Expand All @@ -587,6 +592,7 @@ export class IAAccountSettings
csrfToken=${this.csrfToken}
@ia-authenticated=${(e: CustomEvent) => {
this.lookingToAuth = false;
this.authBy = 'ia';
const { token } = e.detail;
this.dispatchEvent(
new CustomEvent('ready', { detail: { mgcToken: token } })
Expand Down