예제 #1
0
        private Response Login(LoginResource resource)
        {
            var user = _userService.FindUser(resource.Username, resource.Password);

            if (user == null)
            {
                return Context.GetRedirect("~/login?returnUrl=" + (string)Request.Query.returnUrl);
            }

            DateTime? expiry = null;

            if (resource.RememberMe)
            {
                expiry = DateTime.UtcNow.AddDays(7);
            }

            return this.LoginAndRedirect(user.Identifier, expiry);
        }
예제 #2
0
        private Response Login(LoginResource resource)
        {
            Ensure.That(resource.Username, () => resource.Username).IsNotNullOrWhiteSpace();

            // TODO: A null or empty password should not be allowed, uncomment in v3
            //Ensure.That(resource.Password, () => resource.Password).IsNotNullOrWhiteSpace();

            var user = _userService.FindUser(resource.Username, resource.Password);

            if (user == null)
            {
                return Context.GetRedirect("~/login?returnUrl=" + (string)Request.Query.returnUrl);
            }

            DateTime? expiry = null;

            if (resource.RememberMe)
            {
                expiry = DateTime.UtcNow.AddDays(7);
            }

            return this.LoginAndRedirect(user.Identifier, expiry, _configFileProvider.UrlBase + "/");
        }