In Sitecore login can be done with
1. Redirect
2. Removing Read permissions from a Node
3. Custom attribute on the controller
using System.Web;
using System.Web.Mvc;
using Sitecore;
namespace IsacaDP.Foundation.SitecoreExtensions.Attributes
{
public class AuthenticatedAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return Context.User.IsAuthenticated && base.AuthorizeCore(httpContext);
}
protected override void HandleUnauthorizedRequest(AuthorizationContext actionContext)
{
actionContext.Result = new RedirectResult($"~/{Context.Site.LoginPage}?returnUrl={Context.Request.FilePath}?{Context.Request.QueryString}");
}
}
}
and then in controller
using IsacaDP.Foundation.SitecoreExtensions.Attributes;
[Authenticated]
[RedirectingAction]
public class ChapterLeaderController : SitecoreController
{
}
No comments:
Post a Comment