question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Naming of the <dot:IfAuthorized> control

See original GitHub issue

The IfAuthorized control name, which is now in the framework, doesn’t make sense. If the user is not authorized, he won’t even be allowed to open the page. The correct name would be IfAuthenticated, but I don’t like the If in the control name.

In ASP.NET Web Forms, there was the LoginView control which did exactly the same thing - it had AnonymousTemplate and LoggedInTemplate properties, and it also allowed to display different content for each role. In DotVVM, we should have something similar, maybe we could preserve the naming.

<dot:LoginView>
    <AnonymousTemplate>
        This will be displayed to non-authenticated users.
    </AnonymousTemplate>
    <LoggedInTemplate>
        This will be displayed to authenticated users.
    </LoggedInTemplate>
</dot:LoginView>

The role functionality can be easily implemented by a separate control RoleView:

<dot:RoleView Roles="admin,moderator">
    This will be displayed only to the users which have the role
</dot:RoleView>

Also, we could have a similar control for specific app environments:

<dot:EnvironmentView Name="debug">
    This will be displayed only in the debug environment.
</dot:EnvironmentView>

Or shall the control names be IfLoggedIn (or IfAuthenticated), IfInRole (or IfRoleMember), IfEnvironment with templates called TrueTemplate and FalseTemplate?

Do you have another ideas?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
tomashercegcommented, Jun 18, 2016

OK, to sum this up, we just need:

  • A control that renders something for authenticated users and something else for not authenticated users.
  • A control that renders something if the user is or is not in some role.
  • A control that renders something based on the user’s claim.
  • A control that renders something based on the environment (production, test, staging etc.).
  • A control that renders or doesn’t render something based on any server condition.

I don’t want while, goto or fors in the markup, the “if” is just enough. I just wanted the naming to be consistent, that’s why I’ve suggested <dot:IfUser>, <dot:IfEnvironment> and because these classes would probably inherit from some BaseIfControl, why not just add <dot:If> and evaluate the condition on server? This approach would solve all points I have mentioned above, and the naming would be consistent. Also, it would be extensible and we may later need something like <dot:IfConfiguration> etc.

If we name the control <AuthenticatedView>, we have to also think about the names for the other situations - it needs to be consistent because the controls are similar.

P.S. If you want to test the claims and the identity would be GenericPrincipal, I don’t think that we should throw an exception. I’d prefer the condition to be evaluated to false because the generic identity has no claims.

0reactions
quigamdevcommented, Jun 17, 2016

<dot:If Condition="{value: expression}"> this piece of code looks like MSBuild 😄

I prefer AuthenticatedView suggested by @Mylan719 AuthenticatedTemplate and AnonymousTemplate for this component seem to me be OK.

What about to add something like <div RenderSettings.Render="{value: ServerEvaluatedCondition }"> or perhaps <div CanRender="{value: ServerEvaluatedCondition }">? When the condition is false the element is not simply rendered.

I tried to understand why you want the dot:ifsomehting controls. It seem to me like dot:goto.

About the claims. How these components will react when CurrentPrincipal is GenericPrincipal instance?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basic Creation of Name and Title Authorities
Name Authority Cooperative, through which libraries actually contribute authority ... level of authority control and cooperative cataloging!
Read more >
What's in a Name? - NARAtions
The answer is authority control, a library science term that simply means creating and using a single, distinct spelling of a name or...
Read more >
Naming a control
Use the binding object that you created to name the control. To name a control: Procedure. Set the name of the control as...
Read more >
Resources for the Resourceful; Control Point Naming ...
Most control technicians that I know would say that they are happy to name the points in your system any way you would...
Read more >
Naming Controls and Objects | TestComplete Documentation
If it is mapped, then TestComplete uses the mapped name or alias to address this control. Otherwise, it uses the control's ordinary (unmapped)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found