alexziskind1 / nativescript-oauth

Other
35 stars 53 forks source link

Reject login promise on user cancel #74

Closed interrobrian closed 6 years ago

interrobrian commented 6 years ago

Currently, if the user presses the back button to exit the login WebView, the login promise never completes. This can create a few issues:

This PR rejects the promise when the WebView unloads. This works because the web view interceptor runs before unload, so if the promise is going to resolve or reject from that, it still will normally. But, if the view unloads with the promise never being handled, then the new code will reject the promise.

alexziskind1 commented 6 years ago

Thanks for this, Brian. I haven’t had much time to keep this tweaked as it deserves, but I appreciate community members like yourself keeping it going.

On May 31, 2018, at 12:47 PM, Brian Spencer notifications@github.com wrote:

Currently, if the user presses the back button to exit the login WebView, the login promise never completes. This can create a few issues:

It's a memory leak, albeit a small one It can stall the flow when creating an observable from the promise (such as for use with ngrx) This PR rejects the promise when the WebView unloads. This works because the web view interceptor runs before unload, so if the promise is going to resolve or reject from that, it still will normally. But, if the view unloads with the promise never being handled, then the new code will reject the promise.

You can view, comment on, or merge this pull request online at:

https://github.com/alexziskind1/nativescript-oauth/pull/74

Commit Summary

Reject promise when the user cancels login Promise rejection reason Matched indentation on new code to the rest of the project File Changes

M tns-oauth-page-provider.ts (8) A tns-oauth-webview.ts (16) M tns-oauth.ts (2) Patch Links:

https://github.com/alexziskind1/nativescript-oauth/pull/74.patch https://github.com/alexziskind1/nativescript-oauth/pull/74.diff — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.