Esempio n. 1
0
        public void RegisterUser()
        {
            var model = new RegisterModel
            {
                Username = "******",
                Password = "******",
                ConfirmPassword = "******",
                Email = "*****@*****.**",
                Name = "Nestor"
            };

            _Tests.Storage.RegisterUser(model);

            User temp = new User { Username = "******", Email = "*****@*****.**", Password = "******", Name = "Nestor" };

            Assert.AreEqual(temp.Username, _Tests.Storage.GetUser(u => u.Username == "nestor").Username);
        }
Esempio n. 2
0
 public ActionResult Register(RegisterModel registerModel)
 {
     if (_Storage.UsernameExists(registerModel.Username))
     {
         ModelState.AddModelError("Username", "User with such username already exists");
     }
     else if (registerModel.Password != registerModel.ConfirmPassword)
     {
         ModelState.AddModelError("ConfirmPassword", "Passwords don't match");
     }
     
     if (!ModelState.IsValid)
     {
         return View();
     }
     
     _Storage.RegisterUser(registerModel);
     
     return View("Registered");
 }
Esempio n. 3
0
        public ActionResult Register(RegisterModel registerModel)
        {
            if (this.storage.UsernameExists(registerModel.Username))
            {
                this.ModelState.AddModelError("Username", "User with such username already exists");
            }
            else if (registerModel.Password != registerModel.ConfirmPassword)
            {
                this.ModelState.AddModelError("ConfirmPassword", "Passwords don't match");
            }
            
            if (!this.storage.UserOpenIdAvailable(registerModel.OpenId, Guid.Empty))
            {
                this.ModelState.AddModelError("OpenId", Localization.GetMessage("OpenIdError"));

                return this.View();
            }

            if (!this.ModelState.IsValid)
            {
                return this.View();
            }

            this.storage.RegisterUser(registerModel);

            return this.View("Registered");
        }