public LoginViewModel Index(LoginViewModel loginModel) { if (loginModel.HasCredentials()) { var userId = _securityDataService.AuthenticateForUserId(loginModel.Username, loginModel.Password); if (userId.HasValue) { _authContext.ThisUserHasBeenAuthenticated(userId.Value.ToString(), loginModel.RememberMeChecked); loginModel.ErrorMessage = null; loginModel.AuthenticationSuccessful = true; var redirectUrl = loginModel.ReturnUrl.IsNotEmpty() ? loginModel.ReturnUrl : _resolver.Home(); loginModel.ResultOverride = new RedirectResult(redirectUrl); return(loginModel); } loginModel.ErrorMessage = "Invalid username or password"; } return(loginModel); }
public bool TryConvertModel(IndexViewModel model, out SyndicationFeed syndicationFeed) { syndicationFeed = new SyndicationFeed( model.SiteName, model.SiteName, new Uri(_urlResolver.Home()), "AllPostsFeed", new DateTimeOffset(DateTime.Now)) { Description = new TextSyndicationContent(model.SiteName) }; List <SyndicationItem> feedItems = new List <SyndicationItem>(); model.Posts.Each(post => { var feedItem = new SyndicationItem( post.Title, post.Body, new Uri(_urlResolver.PublishedPost(post).ToFullUrl()), new Uri(_urlResolver.PublishedPost(post).ToFullUrl()).ToString(), new DateTimeOffset(post.Published)); feedItem.Authors.Add(new SyndicationPerson(post.User.Email, post.User.DisplayName, post.User.Url)); post.Tags.Each(tag => feedItem.Categories.Add(new SyndicationCategory(tag.Name))); feedItems.Add(feedItem); }); syndicationFeed.Items = feedItems.AsEnumerable(); return(true); }