Skip to content

Commit

Permalink
update user object on token revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
gedaiu committed Apr 23, 2019
1 parent 23e07b3 commit 050047d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

"dependencies": {
"vibe-d": "*",
"fluent-asserts": "~>0.12.1"
"fluent-asserts": "~>0.12.4"
},
"versions": [
"VibeUseOpenSSL11",
Expand Down
4 changes: 4 additions & 0 deletions source/vibeauth/router/registration/routes.d
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ version(unittest) {
string getTemplate(string challangeLocation) {
return "";
}

Json getConfig() {
return Json();
}
}

auto testRouter() {
Expand Down
18 changes: 10 additions & 8 deletions source/vibeauth/users.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -88,8 +88,8 @@ class User {
this(UserData userData) {
this.userData = userData;
}
///

///
this(string email, string password) {
this.userData.email = email;
setPassword(password);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
Expand All @@ -321,7 +324,6 @@ unittest {
assert("tokens" !in json, "It should not contain the tokens");
}


/// User serialization
unittest {
auto user = new User("user", "password");
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 050047d

Please sign in to comment.