Esempio n. 1
0
 public static UniqueUser FromUser(User user)
 {
     return new UniqueUser
            {
            		Id = GenerateUniqueName(user.CompanyId, user.Name),
            		UserId = user.Id
            };
 }
        void HackSecurity()
        {
            var any = RavenSession.Query<User>().Any();
            if (any) return;

            var command = new UserCreateCommand
                          {
                              Email = "*****@*****.**",
                              UserName = AccountController.Administrator,
                              Password = "******",
                              CommandCompanyId = AccountController.AdministratorCompany,
                              CommandByUser = "******",
                              CommandWhen = DateTime.UtcNow
                          };

            var admin = new User();
            admin.Update(command);

            RavenSession.Advanced.UseOptimisticConcurrency = true;
            RavenSession.Store(admin);
            RavenSession.Store(UniqueUser.FromUser(admin));
            RavenSession.SaveChanges();
        }
Esempio n. 3
0
 public bool Equals(User other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Id, Id);
 }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var command = new UserCreateCommand
                {
                    Email = model.Email,
                    UserName = model.UserName,
                    Password = model.Password,
                    CommandCompanyId = model.CommandCompanyId,
                    CommandByUser = model.CommandByUser,
                    CommandWhen = model.CommandWhen
                };

                var user = new User();
                user.Update(command);

                RavenSession.Advanced.UseOptimisticConcurrency = true;
                RavenSession.Store(user);
                RavenSession.Store(UniqueUser.FromUser(user));
                RavenSession.SaveChanges();
                return RedirectToAction("Register");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }