mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 12:53:33 +08:00
closes #146 Add New User interface should have roles (currently redirects to Edit User after user is created)
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4042414
This commit is contained in:
@@ -37,26 +37,31 @@ namespace Orchard.Users.Controllers {
|
||||
public ActionResult Index() {
|
||||
var model = new UsersIndexViewModel();
|
||||
|
||||
var users = _contentManager.Query<User,UserRecord>("user")
|
||||
var users = _contentManager.Query<User, UserRecord>("user")
|
||||
.Where(x => x.UserName != null)
|
||||
.List();
|
||||
|
||||
model.Rows = users.Select(x => new UsersIndexViewModel.Row {User = x}).ToList();
|
||||
model.Rows = users.Select(x => new UsersIndexViewModel.Row { User = x }).ToList();
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public ActionResult Create() {
|
||||
var model = new UserCreateViewModel();
|
||||
var user = _contentManager.New("user");
|
||||
var model = new UserCreateViewModel {
|
||||
Editors = _contentManager.GetEditors(user)
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Create(UserCreateViewModel model) {
|
||||
|
||||
if (model.Password != model.ConfirmPassword) {
|
||||
ModelState.AddModelError("ConfirmPassword", T("Password confirmation must match").ToString());
|
||||
}
|
||||
if (ModelState.IsValid == false) {
|
||||
model.Editors = _contentManager.UpdateEditors(_contentManager.New("user"), this);
|
||||
return View(model);
|
||||
}
|
||||
var user = _membershipService.CreateUser(new CreateUserParams(
|
||||
@@ -64,6 +69,12 @@ namespace Orchard.Users.Controllers {
|
||||
model.Password,
|
||||
model.Email,
|
||||
null, null, true));
|
||||
model.Editors = _contentManager.UpdateEditors(user, this);
|
||||
if (ModelState.IsValid == false) {
|
||||
//TODO: rollback transaction
|
||||
return View(model);
|
||||
}
|
||||
|
||||
return RedirectToAction("edit", new { user.Id });
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user