platform/packages/auth/lib/src/options.dart
Tobe O e887b1d21f Add 'packages/auth/' from commit '1274ad6b0d9c288ab5366e8f3f977e50418166af'
git-subtree-dir: packages/auth
git-subtree-mainline: 6890bbf53f
git-subtree-split: 1274ad6b0d
2020-02-15 18:28:27 -05:00

30 lines
908 B
Dart

import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
import 'auth_token.dart';
typedef FutureOr AngelAuthCallback(
RequestContext req, ResponseContext res, String token);
typedef FutureOr AngelAuthTokenCallback<User>(
RequestContext req, ResponseContext res, AuthToken token, User user);
class AngelAuthOptions<User> {
AngelAuthCallback callback;
AngelAuthTokenCallback<User> tokenCallback;
String successRedirect;
String failureRedirect;
/// 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;
AngelAuthOptions(
{this.callback,
this.tokenCallback,
this.canRespondWithJson = true,
this.successRedirect,
String this.failureRedirect});
}