File tree Expand file tree Collapse file tree 5 files changed +35
-8
lines changed Expand file tree Collapse file tree 5 files changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,10 @@ You can pass the following options:
9191 - Values: ` true ` or ` false `
9292 - Default: ` false `
9393
94+ - ` backTo ` : Redirect back to this url after logout, url must be whitelisted (contact support)
95+ - Values: A string representing a URL
96+ - Default: ` undefined `
97+
9498### Open the setting page of the user account
9599
96100` mtLinkSdk.openSettings(options); `
Original file line number Diff line number Diff line change @@ -11,7 +11,14 @@ <h3>Welcome to the Moneytree Link Web SDK Sample App</h3>
1111 < button id ="authorize-btn "> Authorize</ button >
1212 < button id ="settings-btn "> Open Moneytree Settings</ button >
1313 < button id ="vault-btn "> Open Vault</ button >
14- < button id ="logout-btn "> Logout</ button >
14+ < p >
15+ Logout Url (optional), must be whitelisted
16+ < input id ="logout-url " type ="text " placeholder ="Optional logout url "/>
17+
18+ < div >
19+ < button id ="logout-btn "> Logout</ button >
20+ </ div >
21+ </ p >
1522 </ div >
1623 </ body >
1724</ html >
Original file line number Diff line number Diff line change @@ -29,7 +29,11 @@ authorizeBtn.onclick = () => {
2929
3030// Launch logout route when clicked
3131logoutBtn . onclick = ( ) => {
32- LinkSDK . logout ( ) ;
32+ const value = document . getElementById ( 'logout-url' ) . value ;
33+
34+ LinkSDK . logout ( {
35+ backTo : value ? value : undefined
36+ } ) ;
3337} ;
3438
3539// Launch settings route when clicked
@@ -62,7 +66,7 @@ const validateToken = async () => {
6266 if ( ! accessToken ) {
6367 goToSettingsBtn . disabled = true ;
6468 goToVaultBtn . disabled = true ;
65- logoutBtn . disabled = true ;
69+ // logoutBtn.disabled = true;
6670 return ;
6771 }
6872
Original file line number Diff line number Diff line change 22# yarn lockfile v1
33
44
5- " @moneytree/mt-link-javascript-sdk@file:../ " :
6- version "1.2.3 "
5+ " @moneytree/mt-link-javascript-sdk@file:.. " :
6+ version "1.3.0 "
77 dependencies :
88 conventional-changelog-cli "^2.0.28"
99 qs "^6.9.1"
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ interface IUrlConfig {
4949 email ?: string ;
5050 auth_action ?: string ;
5151 show_auth_toggle ?: boolean ;
52+ back_to ?: string ;
5253}
5354
5455const commonUrlConfig = {
@@ -128,14 +129,25 @@ class LinkSDK {
128129 }
129130
130131 // Open My Account and logs you out from the current session
131- public logout ( { newTab = false } : IMyAccountOptions = { } ) : void {
132+ public logout ( { newTab = false , backTo = '' } : IMyAccountOptions = { } ) : void {
132133 if ( ! this . isInitialized ) {
133134 throw new Error ( 'SDK not initialized' ) ;
134135 }
135136
137+ const newCommonUrlConfig : ICommonUrlConfig & IUrlConfig = { ...commonUrlConfig } ;
138+ const queryString = {
139+ ...this . oauthParams ,
140+ ...this . params
141+ } ;
142+
143+ if ( backTo ) {
144+ delete queryString . redirect_uri ;
145+ newCommonUrlConfig . back_to = backTo ;
146+ }
147+
136148 const params = encodeConfigWithParams < IParams | IOauthParams , ICommonUrlConfig & IUrlConfig > (
137- { ... this . oauthParams , ... this . params } ,
138- { ... commonUrlConfig }
149+ queryString ,
150+ newCommonUrlConfig
139151 ) ;
140152
141153 window . open ( `https://${ this . domains . myaccount } /${ MY_ACCOUNT . PATHS . LOGOUT } ${ params } ` , newTab ? '_blank' : '_self' ) ;
You can’t perform that action at this time.
0 commit comments