Exemplo n.º 1
0
        public ActionResult LogOn(UserAuthentication value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            value.Validate();

            if (value.IsValid)
            {
                var user = this.UserService.GetBy(new UserEmailAddressSpecification(value.EmailAddress));

                this.AuthenticationService.LogOn(user);

                ApplicationSession.Destroy(this.Session);

                var url = value.Redirect;

                if (base.Url.IsLocalUrl(url))
                {
                    return base.Redirect(url);
                }

                return base.RedirectToRoute(CommonRoutes.Index);
            }

            value.CopyToModel(ModelState);

            return base.View(Views.LogOn, value);
        }
Exemplo n.º 2
0
        public void Test_UserAuthentication_Validate()
        {
            var value = new UserAuthentication();

            value.Validate();

            Assert.AreEqual(2, value.Errors.Count, "Errors");
        }