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
|
|
|
|
|
|
|
typedef AngelAuthCallback(
|
2016-12-21 18:28:51 +00:00
|
|
|
RequestContext req, ResponseContext res, String token);
|
2016-12-07 23:09:21 +00:00
|
|
|
|
2017-01-20 23:15:21 +00:00
|
|
|
typedef AngelAuthTokenCallback(
|
|
|
|
RequestContext req, ResponseContext res, AuthToken token, user);
|
|
|
|
|
2016-09-21 06:19:52 +00:00
|
|
|
class AngelAuthOptions {
|
2016-12-07 23:09:21 +00:00
|
|
|
AngelAuthCallback callback;
|
2017-01-20 23:15:21 +00:00
|
|
|
AngelAuthTokenCallback 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,
|
2016-12-07 23:09:21 +00:00
|
|
|
this.canRespondWithJson: true,
|
2016-11-28 01:04:52 +00:00
|
|
|
this.successRedirect,
|
|
|
|
String this.failureRedirect});
|
|
|
|
}
|