diff --git a/src/components/ezp-auth/ezp-auth.tsx b/src/components/ezp-auth/ezp-auth.tsx index 978d538..e61cfa3 100644 --- a/src/components/ezp-auth/ezp-auth.tsx +++ b/src/components/ezp-auth/ezp-auth.tsx @@ -1,4 +1,4 @@ -import { Component, Host, h, Prop, State, Event, EventEmitter, Listen } from '@stencil/core' +import { Component, Host, h, Prop, State, Event, EventEmitter, Listen, Watch } from '@stencil/core' import { EzpAuthorizationService } from '../../services/auth' import authStore from '../../services/auth' import i18next from 'i18next' @@ -13,6 +13,7 @@ export class EzpAuth { @Prop() hidelogin: boolean @Prop() trigger: string @Prop() code: string + @Prop() webview: boolean = false @State() auth: EzpAuthorizationService @State() authURI: string @@ -37,6 +38,17 @@ export class EzpAuth { this.authCancel.emit() } + @Watch('code') + async watchCode(newCode: string) { + if (newCode && newCode.length > 0) { + authStore.state.code = newCode + this.auth.getAccessToken().then(() => { + this.authCancel.emit() + this.authSuccess.emit() + }) + } + } + oauthPopupWindow: Window = null previousUrl = null @@ -47,6 +59,12 @@ export class EzpAuth { return } + // WebView mode: redirect current window instead of opening popup + if (this.webview) { + window.location.href = url + return + } + // remove any existing event listeners window.removeEventListener('message', this.receiveMessage) diff --git a/src/components/ezp-printing/ezp-printing.tsx b/src/components/ezp-printing/ezp-printing.tsx index 022cacd..d7cd9a7 100644 --- a/src/components/ezp-printing/ezp-printing.tsx +++ b/src/components/ezp-printing/ezp-printing.tsx @@ -50,6 +50,7 @@ export class EzpPrinting { @Prop() code: string @Prop() filedata: string @Prop() seamless: boolean = false + @Prop() webview: boolean = false /** * @@ -365,6 +366,7 @@ export class EzpPrinting { hidelogin={this.hidelogin} trigger={this.trigger} code={this.code} + webview={this.webview} > ) : this.printOpen ? (