Thanks, now I understand. The name is for the menu-snippet, right.
> I do not know of any systems that do that. What about using the superuser
> field in MegaProtoUser to denote admin users vs. regular users?
Yeah, that's how I done it before. Or added a roles-enum or something.
In the thing I'm building now, the functionality of admins and
customers are so separated, I first thought that I might build two
different webapps only communicating via a database. But then I
thought WTF and started with one instead.
Anyway, for some reason I really wanted to have separate classes/
tables for them and I'm now trying to follow that path at least for a
few more hours or until I strike a solid wall. Maybe I already have so
heres my next question:
I made a trait that overrides the Locs:
import mapper.{ MetaMegaProtoUser => LiftMetaMegaProtoUser }
trait MetaMegaProtoUser[ModelType <: MegaProtoUser[ModelType]] extends
LiftMetaMegaProtoUser[ModelType] {
self: ModelType =>
val menuNamePrefix: String
override def loginMenuLoc =
Full(Menu(Loc(menuNamePrefix + "Login", loginPath, S.??("login"),
loginMenuLocParams)))
...
override def changePasswordMenuLoc: Box[Menu] =
Full(Menu(Loc(menuNamePrefix + "ChangePassword",
changePasswordPath, S.??("change.password"),
changePasswordMenuLocParams)))
}
and had my Admin companion use this with
val menuNamePrefix = "Admin"
So now the Sitemap works fine and I can create both admin and user
accounts. BUT, the login state doesn't seem to be totally separated.
If I login as a user the menu for the admin appears as if I'm logged
in already. So there is something leaky about the login state of a
ProtoUser, am I right?
If I create an admin called "Admin Adminsson", log out, create a user
called "User Userson" and then click Edit User on the Admin menu, I
get a form populated with "Admin Adminsson" even though I actually
have logged out this admin.
I'm just trying to understand so please be patient with me.
If I follow the path of for instance the logoutMenuLocParams:
protected def logoutMenuLocParams: List[LocParam[Unit]] =
Template(() => wrapIt(logout)) ::
testLogginIn ::
Nil
-> testLogginIn -> .. ->
def loggedIn_? = {
if(!currentUserId.isDefined)
for(f <- autologinFunc) f()
currentUserId.isDefined
}
-> .. ->
private object curUserId extends SessionVar[Box[String]](Empty)
So the curUserId is a SessionVar on ProtoUser trait, but that should
be fine right? I mean it's not shared among subclasses of ProtoUser
since there's no statics in Scala…
So what is the reason that I cannot separate two login states in two
subclasses of ProtoUser?
LiftRules.loggedInTest doesn't have any thing to do with this, has it?
Cheers,
Viktor
> Beginning Scalahttp://
www.apress.com/book/view/1430219890