2018-09-11 22:03:35 +00:00
|
|
|
import 'dart:convert';
|
2017-02-28 22:16:25 +00:00
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
2018-08-26 23:11:37 +00:00
|
|
|
import 'package:http_parser/http_parser.dart';
|
2017-02-28 22:16:25 +00:00
|
|
|
import 'options.dart';
|
|
|
|
|
|
|
|
/// Displays a default callback page to confirm authentication via popups.
|
2019-01-05 23:54:48 +00:00
|
|
|
AngelAuthCallback confirmPopupAuthentication({String eventName = 'token'}) {
|
2018-09-11 22:03:35 +00:00
|
|
|
return (req, ResponseContext res, String jwt) {
|
|
|
|
var evt = json.encode(eventName);
|
|
|
|
var detail = json.encode({'detail': jwt});
|
|
|
|
|
2017-02-28 22:16:25 +00:00
|
|
|
res
|
2019-04-19 07:50:04 +00:00
|
|
|
..contentType = MediaType('text', 'html')
|
2017-02-28 22:16:25 +00:00
|
|
|
..write('''
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<title>Authentication Success</title>
|
|
|
|
<script>
|
2019-05-03 06:27:42 +00:00
|
|
|
var ev = new CustomEvent($evt, $detail);
|
2017-02-28 22:16:25 +00:00
|
|
|
window.opener.dispatchEvent(ev);
|
2017-03-29 00:31:20 +00:00
|
|
|
window.close();
|
2017-02-28 22:16:25 +00:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Authentication Success</h1>
|
|
|
|
<p>
|
|
|
|
Now logging you in... If you continue to see this page, you may need to enable JavaScript.
|
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
''');
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|