Skip to content

Instantly share code, notes, and snippets.

@StefanoChiodino
Last active November 22, 2016 10:29
Show Gist options
  • Save StefanoChiodino/c7c18e5676c31bc865577619c72e6805 to your computer and use it in GitHub Desktop.
Save StefanoChiodino/c7c18e5676c31bc865577619c72e6805 to your computer and use it in GitHub Desktop.
Umbraco: disable front end for client
var userTicket = new System.Web.HttpContextWrapper(System.Web.HttpContext.Current).GetUmbracoAuthTicket();
if (!Request.Url.Host.Equals("localhost", StringComparison.OrdinalIgnoreCase))
{
var user = userTicket?.Name
.IfNotNullThen(()=>ApplicationContext?.Services?.UserService?.GetByUsername(userTicket.Name));
if (user == null)
{
Response.Redirect("/umbraco", true);
}
else if (user.UserType.Alias.Equals("client",StringComparison.OrdinalIgnoreCase))
{
throw new UserAuthorizationException("User is not allowed to preview");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment