Last active
          November 22, 2016 10:29 
        
      - 
      
- 
        Save StefanoChiodino/c7c18e5676c31bc865577619c72e6805 to your computer and use it in GitHub Desktop. 
    Umbraco: disable front end for client
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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