Files
Umbraco-CMS/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs
Shannon f27a0c0461 Merge remote-tracking branch 'origin/6.2.0' into 7.0.2
Conflicts:
	src/Umbraco.Web.UI/Umbraco/PartialViews/Templates/EmptyTemplate.cshtml
	src/Umbraco.Web.UI/umbraco/dialogs/protectPage.aspx
	src/Umbraco.Web/Umbraco.Web.csproj
	src/Umbraco.Web/UmbracoModule.cs
	src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs
2014-01-15 13:28:41 +11:00

55 lines
1.7 KiB
C#

using System;
using System.Web;
using System.Web.Http;
using Umbraco.Core.Configuration;
using Umbraco.Web.Security;
using Umbraco.Web.WebApi.Filters;
using umbraco.BusinessLogic;
namespace Umbraco.Web.WebApi
{
/// <summary>
/// A base controller that ensures all requests are authorized - the user is logged in.
/// </summary>
/// <remarks>
/// This controller will also append a custom header to the response if the user is logged in using forms authentication
/// which indicates the seconds remaining before their timeout expires.
/// </remarks>
[IsBackOffice]
[UmbracoUserTimeoutFilter]
[UmbracoAuthorize]
public abstract class UmbracoAuthorizedApiController : UmbracoApiController
{
protected UmbracoAuthorizedApiController()
{
}
protected UmbracoAuthorizedApiController(UmbracoContext umbracoContext)
: base(umbracoContext)
{
}
private bool _userisValidated = false;
/// <summary>
/// Returns the currently logged in Umbraco User
/// </summary>
[Obsolete("This should no longer be used since it returns the legacy user object, use The Security.CurrentUser instead to return the proper user object")]
protected User UmbracoUser
{
get
{
//throw exceptions if not valid (true)
if (!_userisValidated)
{
Security.ValidateCurrentUser(true);
_userisValidated = true;
}
return new User(Security.CurrentUser);
}
}
}
}