Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to the MegaProtoUser in Lift

Tags:

scala

lift

In Lift, the entire ProtoUser construct is quite awesome, amazing what it does for you, most of the advantages (like many things in Lift, 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.

like image 657
Lanbo Avatar asked Nov 26 '10 12:11

Lanbo


1 Answers

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.

like image 108
RedbeardTheNinja Avatar answered Sep 27 '22 15:09

RedbeardTheNinja