Updates
This commit is contained in:
parent
e67d7adb77
commit
cfdfeebd81
12 changed files with 80 additions and 22 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -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
|
17
.idea/angel.iml
Normal file
17
.idea/angel.iml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/bin/packages" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/test/packages" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/test/services/packages" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/web/packages" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Dart SDK" level="application" />
|
||||
<orderEntry type="library" name="Dart Packages" level="project" />
|
||||
</component>
|
||||
</module>
|
6
.idea/encodings.xml
Normal file
6
.idea/encodings.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/angel.iml" filepath="$PROJECT_DIR$/.idea/angel.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1 +0,0 @@
|
|||
../packages
|
|
@ -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')));
|
||||
}
|
||||
|
|
19
lib/src/routes/controllers/auth.dart
Normal file
19
lib/src/routes/controllers/auth.dart
Normal file
|
@ -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...
|
||||
}
|
||||
}
|
9
lib/src/routes/controllers/controllers.dart
Normal file
9
lib/src/routes/controllers/controllers.dart
Normal file
|
@ -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());
|
||||
}
|
|
@ -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 {}
|
||||
|
||||
|
|
|
@ -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 <thosakwe@gmail.com>
|
||||
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"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../packages
|
Loading…
Reference in a new issue