Project

General

Profile

Auth Module and User Table..

Added by Emir Cem about 13 years ago

Hello,

When new user registers to the application with using RegistrationWidget. AuthModule just adds records to auth_identity table and auth_info table like this;

auth_identity

id 1, version 0, auth_info_id 1, provider loginname, identity emircem

auth_info

id 1, version 0, user_id null, password xxx, password_method bcrypt, password_salt yyy, status 1 ........

Auth Module inserts records only in auth_info table and auth_identity table by default. It does not use User table and it inserts null value in user_id column of auth_info table. How can i make Auth Module use also the User table?

Regards,

Emir Cem


Replies (1)

RE: Auth Module and User Table.. - Added by Jake Petroules about 13 years ago

Believe you should subclass UserDatabase and implement registerNew, like so:

Auth::User SpecializedUserDatabase::registerNew()
{
    Auth::User systemUser = UserDatabase::registerNew();
    if (systemUser.isValid())
    {
        dbo::Transaction t(d->session);

        // Find auth info for the newly registered user
        dbo::ptr<AuthInfo> authInfo = find(systemUser);

        // Attach a new user object to it
        dbo::ptr<User> u = d->session.add(new User());
        authInfo.modify()->setUser(u);

        t.commit();
    }

    return systemUser;
}
    (1-1/1)