public void Authenticate() { var api = new SuperSimpleAuth(LOCAL_KEY, LOCAL_URL); var created = api.CreateUser("test", "test", "*****@*****.**").Result; var user = api.Authenticate("test", "test").Result; Assert.True(!string.IsNullOrEmpty(user.Jwt)); var valid = api.Validate(user).Result; Assert.True(valid); var u = api.Validate(user.AuthToken).Result; Assert.IsNotNull(u); u = api.Validate(user.Jwt); Assert.IsNotNull(u); user.Email = "*****@*****.**"; user = api.ChangeEmail(user, user.Email).Result; user.UserName = "******"; user = api.ChangeUserName(user, user.UserName).Result; valid = api.ChangePassword(user, "pazzwurd").Result; Assert.True(valid); var newpassword = api.Forgot(user.Email).Result; Assert.True(!string.IsNullOrEmpty(newpassword)); valid = api.End(user).Result; Assert.True(valid); valid = api.Validate(user).Result; Assert.False(valid); user = api.Authenticate(user.UserName, newpassword).Result; Assert.IsNotNull(user); valid = api.Disable(user).Result; Assert.True(valid); }
public Planeswalker UpdatePlaneswalker(Planeswalker planeswalker) { MongoCollection <Profile> walkers = database.GetCollection <Profile> ("profiles"); var query = Query <Profile> .EQ(e => e.Id, planeswalker.Id); Profile updateWalker = walkers.FindOne(query); Planeswalker user = null; if (updateWalker != null) { if (updateWalker.Email.ToLower() != planeswalker.Profile.Email.ToLower()) { ssa.ChangeEmail(planeswalker.AuthToken, planeswalker.Profile.Email); } if (updateWalker.Name.ToLower() != planeswalker.Profile.Name.ToLower()) { ssa.ChangeUserName(planeswalker.AuthToken, planeswalker.Profile.Name); } updateWalker.Email = planeswalker.Profile.Email; updateWalker.ModifiedAt = DateTime.Now; updateWalker.Name = planeswalker.Profile.Name; walkers.Save(updateWalker); User ssaUser = ssa.Validate(planeswalker.AuthToken); user = new Planeswalker { UserName = ssaUser.UserName, AuthToken = ssaUser.AuthToken, Email = ssaUser.Email, Id = ssaUser.Id, Claims = ssaUser.Claims, Roles = ssaUser.Roles, Profile = GetProfile(ssaUser.Id) }; } return(user); }