Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simeon Ostberg 123 posts 389 karma points
    Mar 30, 2021 @ 08:24
    Simeon Ostberg
    0

    Umbraco Forms: SecurityRoles?

    Hi everyone,

    We are using Umbraco Forms 7.4.1. I was wondering, if there is a way to use Umbraco Forms with more than one security role? At the moment this seems to be not possible.

    For example, if some user is logged in and part of the group "Accredited" (because he/she has an accreditation) and "Nominee" (in one of our competitions), he/she can't use Umbraco Forms and only gets the message:

    Error loading Partial View script (file: ~/Views/MacroPartials/InsertUmbracoFormWithTheme.cshtml)
    

    When I remove one of the security roles or the user is not logged in, he/she can access the form without problems.

    Is there a way to get it working?

    Best, Simeon

  • Simeon Ostberg 123 posts 389 karma points
    Apr 07, 2021 @ 11:43
    Simeon Ostberg
    0

    Hi everyone,

    I would be happy to get a reply on this...

    Thanks a lot!

    Best, Simeon

  • Huw Reddick 1736 posts 6076 karma points MVP c-trib
    Apr 07, 2021 @ 15:08
    Huw Reddick
    0

    could you post the content of InsertUmbracoFormWithTheme.cshtml

  • Simeon Ostberg 123 posts 389 karma points
    Apr 07, 2021 @ 15:16
    Simeon Ostberg
    0

    Hi Huw,

    Thank you for your reply! Yes, please find it below:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @if (Model.MacroParameters["FormGuid"] != null)
    {
        var s = Model.MacroParameters["FormGuid"].ToString();
        var theme = "";
        var includeScripts = true;
    
        @*
            If a theme is provided as a macro parameter, forms will attempt to use custom theme files
            ex: given the value "test", forms will look up views for the form and fields in a custom directory:
    
            Form will be rendered with
                /Views/Partials/Forms/Themes/test/form.cshml
    
            Fields will be rendered with
                /Views/Partials/Forms/Themes/test/FieldType/[fieldtypename].cshtml
    
            If a file is not available in the custom directory, forms will fallback to the default files in
                /Views/Partials/Forms/Themes/default/
        *@
    
        if(Model.MacroParameters.ContainsKey("FormTheme"))
        {
            theme = Model.MacroParameters["FormTheme"].ToString();
        }
    
        if (Model.MacroParameters.ContainsKey("ExcludeScripts"))
        {
    
            @*
                Inverse the boolean - RenderAction Parameter expects it to be false for exclusion
                But with default value for Macro Paramater boolean/checkbox being false 
                We want to ensure by default we include the scripts next to the form
            *@
            includeScripts = Model.MacroParameters["ExcludeScripts"].ToString() == "0";
        }
    
        var form = new Guid(s);
        var recordGuid = Guid.Empty;
    
        if (string.IsNullOrEmpty(Request.QueryString["recordId"]) == false)
        {
            Guid.TryParse(Request.QueryString["recordId"], out recordGuid);
        }
    
        Html.RenderAction("RenderForm", "UmbracoForms", new {formId = form, recordId = recordGuid, theme = theme, includeScripts = includeScripts });
    }
    

    Best, Simeon

  • Huw Reddick 1736 posts 6076 karma points MVP c-trib
    Apr 07, 2021 @ 19:44
    Huw Reddick
    0

    Nothing in there that relates to security roles, are there any errors in the umbraco log that may give more detail on what is happening?

  • Simeon Ostberg 123 posts 389 karma points
    Apr 08, 2021 @ 11:26
    Simeon Ostberg
    0

    Hi Huw,

    Thanks for your reply. Indeed there are error messages in the log:

    2021-04-08 13:21:30,005 [P6388/D2/T162] WARN  umbraco.macro - Error loading Partial View (file: ~/Views/MacroPartials/InsertUmbracoFormWithTheme.cshtml). Exception: System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. ---> System.ArgumentException: The parameter 'username' must not contain commas.
    Parameter name: username
       at System.Web.Util.SecUtility.CheckParameter(String& param, Boolean checkForNull, Boolean checkIfEmpty, Boolean checkForCommas, Int32 maxSize, String paramName)
       at System.Web.Security.Membership.GetUser(String username, Boolean userIsOnline)
       at Umbraco.Forms.Data.StringHelper.ParsePlaceHolders(HttpContext context, Record record, String value)
       at Umbraco.Forms.Mvc.Models.FormViewModel.Build(Form form)
       at Umbraco.Forms.Web.Controllers.UmbracoFormsController.GetFormModel(Guid formId, Nullable`1 recordId, String theme)
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_6.<BeginInvokeAction>b__4()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
       at System.Web.Mvc.MvcHandler.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
       at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass5_0.<Wrap>b__0()
       at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
       at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
       at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
       at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
       at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
       at System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter)
       at System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper htmlHelper, String actionName, String controllerName, Object routeValues)
       at ASP._Page_Views_MacroPartials_InsertUmbracoFormWithTheme_cshtml.Execute() in C:\Umbraco\Umbraco 2020\Views\MacroPartials\InsertUmbracoFormWithTheme.cshtml:line 47
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
       at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
       at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult)
       at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content)
       at umbraco.macro.LoadPartialViewMacro(MacroModel macro)
       at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
    

    Best, Simeon

  • Huw Reddick 1736 posts 6076 karma points MVP c-trib
    Apr 08, 2021 @ 11:30
    Huw Reddick
    0

    looks like a problem with your username, what is the username you are logging in with?

  • Simeon Ostberg 123 posts 389 karma points
    Apr 08, 2021 @ 11:32
    Simeon Ostberg
    0

    From what I can say, only my last name. I will ask our IT support, if there is more than just the last name.

    Thanks for the moment!

  • Huw Reddick 1736 posts 6076 karma points MVP c-trib
    Apr 08, 2021 @ 12:40
    Huw Reddick
    0

    most likely it has a character in it that it doesn't appear to like

  • Simeon Ostberg 123 posts 389 karma points
    Apr 08, 2021 @ 13:27
    Simeon Ostberg
    0

    Hi Huw,

    Our IT specialist told me, that he debugged Umbraco Forms and found the issue. It was something about the function, how the user name was taken.

    Thanks for the hint to the right way :)

    Best, Simeon

  • Huw Reddick 1736 posts 6076 karma points MVP c-trib
    Apr 08, 2021 @ 13:42
    Huw Reddick
    0

    no problem, glad it helped.

Please Sign in or register to post replies

Write your reply to:

Draft