From 050047dfc84067f02a9f2ace4200cc68ded02292 Mon Sep 17 00:00:00 2001 From: Szabo Bogdan Date: Tue, 23 Apr 2019 17:58:43 +0200 Subject: [PATCH] update user object on token revoke --- dub.json | 2 +- source/vibeauth/router/registration/routes.d | 4 ++++ source/vibeauth/users.d | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/dub.json b/dub.json index 65e8f93..8ac45af 100644 --- a/dub.json +++ b/dub.json @@ -19,7 +19,7 @@ "dependencies": { "vibe-d": "*", - "fluent-asserts": "~>0.12.1" + "fluent-asserts": "~>0.12.4" }, "versions": [ "VibeUseOpenSSL11", diff --git a/source/vibeauth/router/registration/routes.d b/source/vibeauth/router/registration/routes.d index 14e01f5..67df5cf 100644 --- a/source/vibeauth/router/registration/routes.d +++ b/source/vibeauth/router/registration/routes.d @@ -264,6 +264,10 @@ version(unittest) { string getTemplate(string challangeLocation) { return ""; } + + Json getConfig() { + return Json(); + } } auto testRouter() { diff --git a/source/vibeauth/users.d b/source/vibeauth/users.d index 9ac5360..391225a 100644 --- a/source/vibeauth/users.d +++ b/source/vibeauth/users.d @@ -48,14 +48,14 @@ struct UserData { /// string username; - + /// string email; /// string password; - - /// + + /// string salt; /// Flag used to determine if the user can perform any actions @@ -88,8 +88,8 @@ class User { this(UserData userData) { this.userData = userData; } - - /// + + /// this(string email, string password) { this.userData.email = email; setPassword(password); @@ -175,6 +175,10 @@ class User { /// Revoke a token void revoke(string token) { userData.tokens = userData.tokens.filter!(a => a.name != token).array; + + if(onChange) { + onChange(this); + } } const { @@ -305,7 +309,6 @@ unittest { assert(!user.isValidPassword("other passowrd"), "It should return false for an invalid password"); } - /// Converting a user to a public json unittest { auto user = new User("user", "password"); @@ -321,7 +324,6 @@ unittest { assert("tokens" !in json, "It should not contain the tokens"); } - /// User serialization unittest { auto user = new User("user", "password"); @@ -414,7 +416,7 @@ abstract class UserCollection : Collection!User { /// Create a token for an user Token createToken(string email, SysTime expire, string[] scopes = [], string type = "Bearer"); - + /// Revoke a token void revoke(string token);