This commit is contained in:
thosakwe 2017-03-17 15:21:09 -04:00
parent 8bb94fdc08
commit 3564fb4e35
3 changed files with 16 additions and 13 deletions

View file

@ -1,6 +1,6 @@
# angel_client # angel_client
[![pub 1.0.2](https://img.shields.io/badge/pub-1.0.2-brightgreen.svg)](https://pub.dartlang.org/packages/angel_client) [![pub 1.0.3](https://img.shields.io/badge/pub-1.0.3-brightgreen.svg)](https://pub.dartlang.org/packages/angel_client)
[![build status](https://travis-ci.org/angel-dart/client.svg)](https://travis-ci.org/angel-dart/client) [![build status](https://travis-ci.org/angel-dart/client.svg)](https://travis-ci.org/angel-dart/client)
Client library for the Angel framework. Client library for the Angel framework.

View file

@ -1,7 +1,7 @@
/// Browser library for the Angel framework. /// Browser library for the Angel framework.
library angel_client.browser; library angel_client.browser;
import 'dart:async' show Future, Stream, StreamController; import 'dart:async' show Future, Stream, StreamController, Timer;
import 'dart:convert' show JSON; import 'dart:convert' show JSON;
import 'dart:html' show CustomEvent, window; import 'dart:html' show CustomEvent, window;
import 'package:http/browser_client.dart' as http; import 'package:http/browser_client.dart' as http;
@ -53,21 +53,24 @@ class Rest extends BaseAngelClient {
var ctrl = new StreamController<String>(); var ctrl = new StreamController<String>();
var wnd = window.open(url, 'angel_client_auth_popup'); var wnd = window.open(url, 'angel_client_auth_popup');
wnd new Timer.periodic(new Duration(milliseconds: 500), (timer) {
..on['beforeunload'].listen((_) { if (!ctrl.isClosed) {
if (!ctrl.isClosed) { if (wnd.closed) {
ctrl.addError(new AngelHttpException.notAuthenticated( ctrl.addError(new AngelHttpException.notAuthenticated(
message: message:
errorMessage ?? 'Authentication via popup window failed.')); errorMessage ?? 'Authentication via popup window failed.'));
ctrl.close(); ctrl.close();
} }
}) } else
..on[eventName ?? 'token'].listen((CustomEvent e) { timer.cancel();
if (!ctrl.isClosed) { });
ctrl.add(e.detail);
ctrl.close(); window.on[eventName ?? 'token'].listen((CustomEvent e) {
} if (!ctrl.isClosed) {
}); ctrl.add(e.detail);
ctrl.close();
}
});
return ctrl.stream; return ctrl.stream;
} }

View file

@ -1,5 +1,5 @@
name: angel_client name: angel_client
version: 1.0.2 version: 1.0.3
description: Client library for the Angel framework. description: Client library for the Angel framework.
author: Tobe O <thosakwe@gmail.com> author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_client homepage: https://github.com/angel-dart/angel_client