Logging access denied events. Renaming DevTools _Package.txt to disable it by default.

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045028
This commit is contained in:
loudej
2010-01-06 04:49:55 +00:00
parent 207e1f38be
commit 79bfc390f3
3 changed files with 16 additions and 5 deletions

View File

@@ -76,7 +76,7 @@
<Compile Include="ViewModels\ContentDetailsViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Package.txt" />
<Content Include="_Package.txt" />
<Content Include="Views\Content\Details.aspx" />
<Content Include="Views\Content\Index.aspx" />
<Content Include="Views\Home\Index.aspx" />

View File

@@ -4,6 +4,7 @@ using System.Globalization;
using System.Security.Principal;
using System.Web.Mvc;
using System.Web.Security;
using Orchard.Logging;
using Orchard.Mvc.ViewModels;
using Orchard.Security;
using Orchard.Users.ViewModels;
@@ -15,15 +16,25 @@ namespace Orchard.Users.Controllers {
private readonly IMembershipService _membershipService;
public AccountController(IAuthenticationService authenticationService, IMembershipService membershipService) {
public AccountController(
IAuthenticationService authenticationService,
IMembershipService membershipService) {
_authenticationService = authenticationService;
_membershipService = membershipService;
Logger = NullLogger.Instance;
}
public ActionResult AccessDenied(string returnUrl) {
if (_authenticationService.GetAuthenticatedUser() == null)
return View("LogOn", new LogOnViewModel { Title = "Access Denied", ReturnUrl = returnUrl });
public ILogger Logger { get; set; }
public ActionResult AccessDenied(string returnUrl) {
var currentUser = _authenticationService.GetAuthenticatedUser();
if (currentUser == null) {
Logger.Information("Access denied to anonymous request on {0}", returnUrl);
return View("LogOn", new LogOnViewModel { Title = "Access Denied", ReturnUrl = returnUrl });
}
Logger.Information("Access denied to user #{0} '{1}' on {2}", currentUser.Id, currentUser.UserName, returnUrl);
return View(new BaseViewModel());
}