From cfdfeebd8169b52672a08bbc2a774290518571a0 Mon Sep 17 00:00:00 2001 From: regiostech Date: Tue, 5 Jul 2016 17:11:54 -0400 Subject: [PATCH] Updates --- .gitignore | 4 ++++ .idea/angel.iml | 17 +++++++++++++++++ .idea/encodings.xml | 6 ++++++ .idea/misc.xml | 14 ++++++++++++++ .idea/modules.xml | 8 ++++++++ bin/packages | 1 - lib/src/config/config.dart | 19 ------------------- lib/src/routes/controllers/auth.dart | 19 +++++++++++++++++++ lib/src/routes/controllers/controllers.dart | 9 +++++++++ lib/src/routes/routes.dart | 1 + pubspec.yaml | 3 ++- web/packages | 1 - 12 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 .idea/angel.iml create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml delete mode 120000 bin/packages create mode 100644 lib/src/routes/controllers/auth.dart create mode 100644 lib/src/routes/controllers/controllers.dart delete mode 120000 web/packages diff --git a/.gitignore b/.gitignore index 1c74d02..9df8641 100644 --- a/.gitignore +++ b/.gitignore @@ -110,3 +110,7 @@ pubspec.lock # Don't commit pubspec lock file # (Library packages only! Remove pattern if developing an application package) + +packages +**/packages +bin/packages \ No newline at end of file diff --git a/.idea/angel.iml b/.idea/angel.iml new file mode 100644 index 0000000..dfd40b9 --- /dev/null +++ b/.idea/angel.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..bfb1eab --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b034384 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/bin/packages b/bin/packages deleted file mode 120000 index a16c405..0000000 --- a/bin/packages +++ /dev/null @@ -1 +0,0 @@ -../packages \ No newline at end of file diff --git a/lib/src/config/config.dart b/lib/src/config/config.dart index 70187e1..7dde821 100644 --- a/lib/src/config/config.dart +++ b/lib/src/config/config.dart @@ -2,31 +2,12 @@ library angel.config; import 'dart:io'; -import 'package:angel_auth/angel_auth.dart'; import 'package:angel_configuration/angel_configuration.dart'; import 'package:angel_framework/angel_framework.dart'; import 'package:angel_mustache/angel_mustache.dart'; /// This is a perfect place to include configuration and load plug-ins. configureServer(Angel app) async { - AngelAuthOptions localOpts = new AngelAuthOptions( - failureRedirect: '/failure', successRedirect: '/success'); - Map sampleUser = {'hello': 'world'}; - - verifier(username, password) async { - if (username == 'username' && password == 'password') { - return sampleUser; - } else - return false; - } - - wireAuth(Angel app) async { - Auth.serializer = (user) async => 1337; - Auth.deserializer = (id) async => sampleUser; - - Auth.strategies.add(new LocalAuthStrategy(verifier)); - await app.configure(AngelAuth); - } await app.configure(loadConfigurationFile()); await app.configure(mustache(new Directory('views'))); } diff --git a/lib/src/routes/controllers/auth.dart b/lib/src/routes/controllers/auth.dart new file mode 100644 index 0000000..53ff017 --- /dev/null +++ b/lib/src/routes/controllers/auth.dart @@ -0,0 +1,19 @@ +part of angel.routes.controllers; + +@Expose("/auth") +class AuthController extends Controller { + @override + call(Angel app) async { + app.registerMiddleware("auth", (req, res) async { + if (req.session['userId'] == null) + throw new AngelHttpException.Forbidden(); + + return true; + }); + } + + @Expose("/login", method: "POST") + login(RequestContext req) async { + // Include log-in logic here... + } +} diff --git a/lib/src/routes/controllers/controllers.dart b/lib/src/routes/controllers/controllers.dart new file mode 100644 index 0000000..15f395f --- /dev/null +++ b/lib/src/routes/controllers/controllers.dart @@ -0,0 +1,9 @@ +library angel.routes.controllers; + +import 'package:angel_auth/angel_auth.dart'; +import 'package:angel_framework/angel_framework.dart'; +part 'auth.dart'; + +configureServer(Angel app) async { + await app.configure(new AuthController()); +} diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index 2801c48..954eee2 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.dart @@ -3,6 +3,7 @@ library angel.routes; import 'package:angel_framework/angel_framework.dart'; import 'package:angel_static/angel_static.dart'; +import 'controllers/controllers.dart' as Controllers; configureBefore(Angel app) async {} diff --git a/pubspec.yaml b/pubspec.yaml index 07fce40..a2d005f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,9 @@ name: angel description: An easily-extensible web server framework in Dart. -version: 0.0.0-dev.0 +version: 1.0.0-dev author: thosakwe homepage: https://github.com/angel-dart/angel +publish_to: none dependencies: angel_auth: ">=1.0.0-dev <2.0.0" angel_configuration: ">=1.0.0-dev <2.0.0" diff --git a/web/packages b/web/packages deleted file mode 120000 index a16c405..0000000 --- a/web/packages +++ /dev/null @@ -1 +0,0 @@ -../packages \ No newline at end of file