public void CreateNew(Options options) { bool errored = false; if (string.IsNullOrEmpty(options.Name)) { WriteErrorLine("Rbac name is required"); errored = true; } if (string.IsNullOrEmpty(options.AppCs)) { WriteErrorLine("Application connection string is required"); errored = true; } if (errored) { return; } Rbac rbac = new Rbac(); rbac.Callback += Rbac_Callback; Rbac newRbac = rbac.CreateNew(options.Name, options.Description, options.AppCs, string.Empty); rbac.ChangePassword(options.Password); WriteColor(ConsoleColor.Green, "Done!" + Environment.NewLine); Console.WriteLine(); Console.Write("Rbac '{0}' was created with id '{1}. Now it's time to configure some roles & users in the RBAC website.", options.Name, newRbac.RbacId); Console.WriteLine(); }
public async Task <IHttpActionResult> SetPassword(SetPassword newPassword) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Rbac.ChangePassword(User.Identity.GetUserName(), newPassword.OldPassword, newPassword.NewPassword)) { return(Ok()); } return(BadRequest("User is not defined!")); }