I am not using Monorail for the moment and I don't know on what level you
want customize your page depending on authorization but I think you can do
something with ViewComponents:
e.g.
public class LoginViewComponent:ViewComponent
    {
        private class Fields
        {
public const string Username= "Username";

        }
        public override void Render()
        {
            RolePrincipal
rolePrincipal=SecurityHelper.GetCurrentUser(this.EngineContext);

            if (rolePrincipal== null)
                Context.RenderSection("anonymous");
            else
            {
                PropertyBag[Fields.Username] = rolePrincipal.Identity.Name;
                Context.RenderSection("loggedIn");
            }
        }
        public override bool SupportsSection(string name)
        {
            return name == "loggedIn" || name == "anonymous";
        }

    }

which you then can use as follows from NVelocity:

 #blockcomponent (LoginViewComponent)
        #loggedIn
        Welcome $username |
        $HtmlHelper.LinkTo("$layout.logout","login","logout")
        #end
        #anonymous

 
$AjaxHelper.LinkToRemote("$layout.login",$UrlHelper.For($DictHelper.CreateDict("controller=login",
"action=ajaxshow","querystring=returnUrl=home/index.vm")),$DictHelper.CreateDict("update=maindiv"))
        |

 
$AjaxHelper.LinkToRemote("$layout.register",$UrlHelper.For($DictHelper.CreateDict("controller=userregister",
"action=index","querystring=returnUrl=home/index.vm")),$DictHelper.CreateDict("update=maindiv"))
        #end
        #end

All depends of course what exactly you want to do...


On Tue, Oct 28, 2008 at 2:34 AM, c.sokun <[EMAIL PROTECTED]> wrote:

>
> Thanks a lot, one last thing I am not quiet sure how to make this new
> security work with SecurityComponent.
> Problem is I want to render part of my page base on the user role.
> It seem to me like the User class need to implement two interface
> IUser, IPrincipal but then I got an idea of passing passing a userRole
> as variable to view like this
>
> PropertyBag["userRole"] = "Administrator";
>
> and then in the view instead of using SecurityComponent I would do an
> if block.
> If that how I should do or is there a better way built-in already?
>
>
> On Oct 28, 2:39 am, "Bart Reyserhove" <[EMAIL PROTECTED]>
> wrote:
> > You are correct. Rhino Security is designed for authorization purposes,
> we
> > use it to check whether someone can do something.We use Membership
> provider
> > for the authentication part. The two of them work together perfectly
> >
> > On Mon, Oct 27, 2008 at 9:07 AM, c.sokun <[EMAIL PROTECTED]> wrote:
> >
> > > Am I correct to say Rhino.Security was not design to replace ASP.NET
> > > Membership model?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to