401 -> 403
This commit is contained in:
parent
5faaceefa4
commit
ef6050f0d4
3 changed files with 14 additions and 9 deletions
|
@ -7,7 +7,7 @@ Future<bool> requireAuth(RequestContext req, ResponseContext res,
|
||||||
return true;
|
return true;
|
||||||
else if (throws) {
|
else if (throws) {
|
||||||
res.status(HttpStatus.UNAUTHORIZED);
|
res.status(HttpStatus.UNAUTHORIZED);
|
||||||
throw new AngelHttpException.NotAuthenticated();
|
throw new AngelHttpException.Forbidden();
|
||||||
}
|
}
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
|
@ -73,14 +73,19 @@ class LocalAuthStrategy extends AuthStrategy {
|
||||||
..header(HttpHeaders.WWW_AUTHENTICATE, 'Basic realm="$realm"')
|
..header(HttpHeaders.WWW_AUTHENTICATE, 'Basic realm="$realm"')
|
||||||
..end();
|
..end();
|
||||||
return false;
|
return false;
|
||||||
} else throw new AngelHttpException.NotAuthenticated();
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
req.session['user'] = await Auth.serializer(verificationResult);
|
else if (verificationResult != null && verificationResult != false) {
|
||||||
if (options.successRedirect != null && options.successRedirect.isNotEmpty) {
|
req.session['userId'] = await Auth.serializer(verificationResult);
|
||||||
|
if (options.successRedirect != null &&
|
||||||
|
options.successRedirect.isNotEmpty) {
|
||||||
return res.redirect(options.successRedirect, code: HttpStatus.OK);
|
return res.redirect(options.successRedirect, code: HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
throw new AngelHttpException.NotAuthenticated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: angel_auth
|
name: angel_auth
|
||||||
description: A complete authentication plugin for Angel.
|
description: A complete authentication plugin for Angel.
|
||||||
version: 1.0.0-dev
|
version: 1.0.0-dev+5
|
||||||
author: thosakwe <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel_auth
|
homepage: https://github.com/angel-dart/angel_auth
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: ">=0.0.0-dev < 0.1.0"
|
angel_framework: ">=0.0.0-dev < 0.1.0"
|
||||||
|
|
Loading…
Reference in a new issue