Project

General

Profile

Correct way to specialize WRegistrationWidget

Added by Sergey Perunov about 12 years ago

Hi guys,

I need to add some fields to the registration widget. I'd like to know if what I am doing is right and make sure that I'm using the framework as intended.

Here is my plan:

1) Change the "Wt.Auth.template.registration" template to add more fields.

2) Subclass the Wt::Auth::RegistrationWidget and re-implement createFormWidget() for the above to work.

3) In my sub-classed Wt::Auth::AuthModel, make sure that validateField() works for the above correctly.

4) Implement the Wt::Auth::RegistrationWidget::registerUserDetails()

Could someone tell me if this is the correct approach, and am I on the right track?

Side-note: It would have been totally awesome if RegistrationWidget had some utility functions like addTextField(&User::Field, labelText, validatorFunction = 0). That way people could do all of the above in a one-liner. Right now, as a user of the Auth framework it feels like I am forced to learn too much about how it works to do anything but the trivial implementation. On the other hand, maybe this concern could be alleviated with a good example/tutorial.

Thanks all!


Replies (14)

RE: Correct way to specialize WRegistrationWidget - Added by Koen Deforche about 12 years ago

Hey,

Last night I worked on an example that does this which I'll push to git later today.

Regards,

Koen

RE: Correct way to specialize WRegistrationWidget - Added by Gustavo Sooeiro almost 12 years ago

Hey Koen,

What example are you talking about?

Regards,

Gustavo

RE: Correct way to specialize WRegistrationWidget - Added by Koen Deforche almost 12 years ago

Hey Gustavo,

examples/feature/auth2

Regards,

koen

RE: Correct way to specialize WRegistrationWidget - Added by Gustavo Sooeiro almost 12 years ago

Thanks Koen,

One more thing, I am using the hangman example as the main program to test other functionality taken from other examples. As the hangman already has the User.h and .C files, related to the User class, how should I proceed regarding the User class from Auth2 example?

Should I change the class name?

Should I use the same class?

Thanks,

Gustavo

RE: Correct way to specialize WRegistrationWidget - Added by Gustavo Sooeiro almost 12 years ago

I used the same class, and made all the proper changes. The app compiled ok, but when I try to make a registration the console gives an error and craches the app:

Wt: error during event handling: Class 4User was not mapped.

Any clue about that?

thanks a lot,

Regards,

Gustavo

RE: Correct way to specialize WRegistrationWidget - Added by Koen Deforche almost 12 years ago

You need to make sure you call session.mapClass() for every Wt::Dbo class type.

Regards,

koen

RE: Correct way to specialize WRegistrationWidget - Added by Gustavo Sooeiro almost 12 years ago

Yes, Koen, indeed, and I am using the same code as you are and we've mapped:

mapClass

mapClass

mapClassAuthInfo::AuthIdentityType

mapClassAuthInfo::AuthTokenType

I can't see any other class I should map as the field created goes to the User class.

Can you point me where to look in to?

Thanks,

Gustavo

RE: Correct way to specialize WRegistrationWidget - Added by Koen Deforche almost 12 years ago

Hey Gustavo,

Perhaps you should make sure you have the right 'User' (not Wt::Auth::User but your own User), possibly by not importing the Wt::Auth namespace or by explicitly scoping User, e.g. mapClass< ::User >

Regards,

koen

RE: Correct way to specialize WRegistrationWidget - Added by Gustavo Sooeiro almost 12 years ago

Koen,

I am already doing that, as the hangman example already does like you just said. Its using a session_.mapClass.

Is that right, right?

BR,

Gustavo

RE: Correct way to specialize WRegistrationWidget - Added by Gustavo Sooeiro almost 12 years ago

The only thing that came to my mind right now is that I am using the fields from the hangman example. Should I include these fields in any method to save all fields together?

RE: Correct way to specialize WRegistrationWidget - Added by Gustavo Sooeiro almost 12 years ago

Its curious that I don't have a class named 4User anywere, but the console message shows I should map it.

Again, the messages are:

Warning: Wt::Dbo exiting with 1 dirty objects

Warning: Wt::Dbo exiting with 1 dirty objects

terminated called after throwing an instance of 'Wt::Dbo::Exception' what(): Class 4User was not mapped.

RE: Correct way to specialize WRegistrationWidget - Added by Jeremy Minton over 10 years ago

Was this ever resolved?

I seem to have a similar problem trying to follow Auth1:

[2014-May-04 14:30:48.275305] 23757 [/ 1NUGhzcuO8nyZQTX] [error] "Wt: error during event handling: Class N2Wt4Auth3Dbo8AuthInfoI6MyUserEE was not mapped."
[2014-May-04 14:30:48.275423] 23757 [/ 1NUGhzcuO8nyZQTX] [error] "Wt: fatal error: Class N2Wt4Auth3Dbo8AuthInfoI6MyUserEE was not mapped."

Yet I am mapping

     session_.mapClass< ::MyUser>("user");
     session_.mapClass<AuthInfo>("auth_info");
     session_.mapClass<AuthInfo::AuthIdentityType>("auth_identity");
     session_.mapClass<AuthInfo::AuthTokenType>("auth_token");

Thanks in advance,

Jeremy

RE: Correct way to specialize WRegistrationWidget - Added by Jeremy Minton over 10 years ago

Cancel that, I found the error.

I was using two instances of the Session object due to confusion between the Hangman and Auth1 examples, where the former has the dbo::Session as an object of the user defined Session class and the latter inherits from it.

Regards,

    (1-14/14)