Search code examples
scalalift

Several login levels in Lift


Let's say I have two user models:

object Customer extends Customer with KeyedMetaMapper[Long, Customer] with MetaMegaProtoUser[Customer]
object User extends User with MetaMegaProtoUser[User]

Both from MegaProtoUser. One is for the frontend, one is for the admin login only, and they're completely different. Now I think I have to add both to the sitemap:

class Boot {
    def boot {
        val sitemap = List(
            Menu.i("Home") / "index",
            Menu.i("Admin") / "admin" / "index" submenus User.menus
        ) ::: Customer.menus
        LiftRules.setSiteMap(SiteMap(sitemap:_*))
    }
}

Seems quite simple to me, but it throws an exception:

net.liftweb.sitemap.SiteMapException: Location Login defined twice
    Loc(Login, <function1>, LinkText(<function1>), List(If(<function0>,<function0>), Template(<function0>))) 
and
    Loc(Login, <function1>, LinkText(<function1>), List(LocGroup(WrappedArray(public)),If(<function0>,<function0>), Template(<function0>)))

How could I add the second login and user edit areas for the Admin user?


Solution

  • (From looking at proto/ProtoUser.scala) Override this:

    /** * If you have more than 1 ProtoUser in your application, you'll need to distinguish the menu names. * Do so by changing the menu name suffix so that there are no name clashes */ protected def menuNameSuffix: String = ""

    So if you set it to "xx" then instead of Login the menu name will be Loginxx.