void SetUserAsCurrent(User user) { string userType = user.IsAdministrator ? "Administrator" : "User"; IIdentity identity = new GenericIdentity(user.Name, userType); HttpContext.User = new GenericPrincipal(identity, new string[] { userType }); Session.RemoveAll(); Session.Add(USER_SESSION_KEY, user); }
public User Update(User dataObject) { throw new NotImplementedException(); }
public JsonResult Register(string name, string password, string email) { User newUser = new User { Name = name, Password = password, Email = email, IsActive = true, IsAdministrator = false }; Repository.Update(newUser); SetUserAsCurrent(newUser); return LogIn(newUser.Email, newUser.Password); }