From 148c9cbc18108b5f7eb867591df10cd777c6f80c Mon Sep 17 00:00:00 2001 From: thosakwe Date: Sun, 27 Nov 2016 20:04:52 -0500 Subject: [PATCH] +11 --- README.md | 2 +- lib/src/options.dart | 8 ++++++-- lib/src/plugin.dart | 3 ++- pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3fd2c055..c2499db5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # angel_auth -![version 1.1.0-dev+10](https://img.shields.io/badge/version-1.1.0--dev+10-red.svg) +![version 1.1.0-dev+11](https://img.shields.io/badge/version-1.1.0--dev+11-red.svg) ![build status](https://travis-ci.org/angel-dart/auth.svg?branch=master) A complete authentication plugin for Angel. Inspired by Passport. diff --git a/lib/src/options.dart b/lib/src/options.dart index be01c5c3..13b66d9d 100644 --- a/lib/src/options.dart +++ b/lib/src/options.dart @@ -1,6 +1,10 @@ class AngelAuthOptions { + bool canRespondWithJson; String successRedirect; String failureRedirect; - AngelAuthOptions({String this.successRedirect, String this.failureRedirect}); -} \ No newline at end of file + AngelAuthOptions( + {this.canRespondWithJson: true, + this.successRedirect, + String this.failureRedirect}); +} diff --git a/lib/src/plugin.dart b/lib/src/plugin.dart index ff7900f0..94c49775 100644 --- a/lib/src/plugin.dart +++ b/lib/src/plugin.dart @@ -232,7 +232,8 @@ class AngelAuth extends AngelPlugin { if (allowCookie) req.cookies.add(new Cookie("token", jwt)); - if (req.headers.value("accept") != null && + if (options?.canRespondWithJson != false && + req.headers.value("accept") != null && (req.headers.value("accept").contains("application/json") || req.headers.value("accept").contains("*/*") || req.headers.value("accept").contains("application/*"))) { diff --git a/pubspec.yaml b/pubspec.yaml index 78222c14..5aa79fc2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_auth description: A complete authentication plugin for Angel. -version: 1.0.0-dev+10 +version: 1.0.0-dev+11 author: Tobe O homepage: https://github.com/angel-dart/angel_auth dependencies: