2018-09-11 22:11:44 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2016-12-07 23:09:21 +00:00
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
2017-01-20 23:15:21 +00:00
|
|
|
import 'auth_token.dart';
|
2016-12-07 23:09:21 +00:00
|
|
|
|
2018-09-11 22:11:44 +00:00
|
|
|
typedef FutureOr AngelAuthCallback(
|
2016-12-21 18:28:51 +00:00
|
|
|
RequestContext req, ResponseContext res, String token);
|
2016-12-07 23:09:21 +00:00
|
|
|
|
2018-09-11 22:11:44 +00:00
|
|
|
typedef FutureOr AngelAuthTokenCallback<User>(
|
|
|
|
RequestContext req, ResponseContext res, AuthToken token, User user);
|
2017-01-20 23:15:21 +00:00
|
|
|
|
2018-09-11 22:11:44 +00:00
|
|
|
class AngelAuthOptions<User> {
|
2016-12-07 23:09:21 +00:00
|
|
|
AngelAuthCallback callback;
|
2018-09-11 22:11:44 +00:00
|
|
|
AngelAuthTokenCallback<User> tokenCallback;
|
2016-09-21 06:19:52 +00:00
|
|
|
String successRedirect;
|
|
|
|
String failureRedirect;
|
|
|
|
|
2018-07-12 17:20:47 +00:00
|
|
|
/// If `false` (default: `true`), then successful authentication will return `true` and allow the
|
|
|
|
/// execution of subsequent handlers, just like any other middleware.
|
|
|
|
///
|
|
|
|
/// Works well with `Basic` authentication.
|
|
|
|
bool canRespondWithJson;
|
|
|
|
|
2016-11-28 01:04:52 +00:00
|
|
|
AngelAuthOptions(
|
2016-12-07 23:09:21 +00:00
|
|
|
{this.callback,
|
2017-01-20 23:15:21 +00:00
|
|
|
this.tokenCallback,
|
2019-01-05 23:54:48 +00:00
|
|
|
this.canRespondWithJson = true,
|
2016-11-28 01:04:52 +00:00
|
|
|
this.successRedirect,
|
|
|
|
String this.failureRedirect});
|
|
|
|
}
|