开发者

Alternative to the MegaProtoUser in Lift

开发者 https://www.devze.com 2023-01-27 06:25 出处:网络
In Lift, the entire ProtoUser construct is quite awesome, amazing what it does for you, most of the advantages (like many things in Lift,开发者_StackOverflow unfortunately) undocumented.

In Lift, the entire ProtoUser construct is quite awesome, amazing what it does for you, most of the advantages (like many things in Lift,开发者_StackOverflow unfortunately) undocumented.

There is just one problem: It holds data I don't need and even data I don't want. For example, I want my user to login by a nickname, and I don't need to know his location, locale or first/last name. But at sign-up, I require information that is not displayed on the standard sign-up page.

My first idea would be to re-write my own User trait, but then I would have to re-write all the session-ing code, authorisation, etc. Is there an alternative already? Or is it possible to alter the ProtoUser to have my own sign-up and login pages, as well as only my necessary data?

Thanks for listening.


I am not sure if there is any easy way to remove any of the fields in ProtoUser but one option would be to look into the fieldOrder method in ProtoUser, I believe that defines the fields that protoUser uses. As to the sign up problem there is a method signUpFields that lets you override what fields you require at sign up like so

override def signupFields = email :: userName :: password :: Nil

Assuming you define your own userName object. There is also a similar method for editFields, this doesn't actually solve the problem of removing fields that it keeps track of but perhaps fieldOrder might do something, another suggestion I would have is to look at the source of Proto User and see if you can maybe override the mapped objects and make mapper ignore them somehow. This is still just a way of working around Proto User to avoid having to rewrite a lot of the code it contains.

0

精彩评论

暂无评论...
验证码 换一张
取 消