Update auth.dart
This commit is contained in:
parent
f36d145c7a
commit
0382a7ffb6
1 changed files with 10 additions and 10 deletions
|
@ -4,15 +4,15 @@ import 'package:angel_auth/angel_auth.dart';
|
|||
import 'package:angel_framework/angel_framework.dart';
|
||||
import '../../services/user.dart';
|
||||
|
||||
@Expose("/auth")
|
||||
@Expose("/api/auth")
|
||||
class AuthController extends Controller {
|
||||
final AngelAuth _auth = new AngelAuth();
|
||||
final AngelAuth auth = new AngelAuth();
|
||||
|
||||
_deserializer(String id) async => app.service("api/users").read(id);
|
||||
_serializer(User user) async => user.id;
|
||||
deserializer(String id) async => app.service("api/users").read(id);
|
||||
serializer(User user) async => user.id;
|
||||
|
||||
/// Attempt to log a user in
|
||||
_verifier(UserService Users) {
|
||||
verifier(UserService Users) {
|
||||
return (String username, String password) async {
|
||||
List<User> users = await Users.index({"username": username});
|
||||
|
||||
|
@ -27,13 +27,13 @@ class AuthController extends Controller {
|
|||
@override
|
||||
call(Angel app) async {
|
||||
// Wire up local authentication, connected to our User service
|
||||
_auth.serializer = _serializer;
|
||||
_auth.deserializer = _deserializer;
|
||||
_auth.strategies
|
||||
.add(new LocalAuthStrategy(_verifier(app.container.make(UserService))));
|
||||
auth.serializer = serializer;
|
||||
auth.deserializer = deserializer;
|
||||
auth.strategies
|
||||
.add(new LocalAuthStrategy(verifier(app.container.make(UserService))));
|
||||
|
||||
await super.call(app);
|
||||
await app.configure(_auth);
|
||||
await app.configure(auth);
|
||||
}
|
||||
|
||||
bool loggedIn(RequestContext req) => req.session["userId"] != null;
|
||||
|
|
Loading…
Reference in a new issue