Hi,
I had this topic quite a while ago. I would like to use several Links installations on one server with one Login (not Community).
I thought it would be a good and easy going idea to PRE and POST change database anytime user data is accessed.
$mgr->install_hooks('ONEUSERDB', [['user_signup', 'PRE', 'Plugins::ONEUSERDB::user_signup', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_validate', 'PRE', 'Plugins::ONEUSERDB::user_validate', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_validate_email', 'PRE', 'Plugins::ONEUSERDB::user_validate_email', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_pass_email', 'PRE', 'Plugins::ONEUSERDB::user_pass_email', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_valid_user', 'PRE', 'Plugins::ONEUSERDB::auth_valid_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_get_pass', 'PRE', 'Plugins::ONEUSERDB::auth_get_pass', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_get_user', 'PRE', 'Plugins::ONEUSERDB::auth_get_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_valid_session', 'PRE', 'Plugins::ONEUSERDB::auth_valid_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_create_session', 'PRE', 'Plugins::ONEUSERDB::auth_create_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_delete_session', 'PRE', 'Plugins::ONEUSERDB::auth_delete_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['init_user', 'PRE', 'Plugins::ONEUSERDB::init_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_login', 'POST', 'Plugins::ONEUSERDB::post_user_login', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_signup', 'POST', 'Plugins::ONEUSERDB::post_user_signup', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_validate', 'POST', 'Plugins::ONEUSERDB::post_user_validate', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_validate_email', 'POST', 'Plugins::ONEUSERDB::post_user_validate_email', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_pass_email', 'POST', 'Plugins::ONEUSERDB::post_user_pass_email', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_valid_user', 'POST', 'Plugins::ONEUSERDB::post_auth_valid_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_get_pass', 'POST', 'Plugins::ONEUSERDB::post_auth_get_pass', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_get_user', 'POST', 'Plugins::ONEUSERDB::auth_get_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_valid_session', 'POST', 'Plugins::ONEUSERDB::post_auth_valid_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_create_session', 'POST', 'Plugins::ONEUSERDB::post_auth_create_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_delete_session', 'POST', 'Plugins::ONEUSERDB::post_auth_delete_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['init_user', 'POST', 'Plugins::ONEUSERDB::post_init_user', '']]);
Where there is the following in ONEUSERDB:
use GT::SQL;
my $ONEUSERDB = GT::SQL->new({def_path => '/path_to_oneuserdb/cgi-bin/admin/defs',cache => 1});
my $REGULARDB = GT::SQL->new({def_path => '/path_to_regular/cgi-bin/admin/defs',cache => 1});
And for any of the above subroutines:
$DB = $ONEUSERDB;
return;
}
sub post_user_login {
$DB = $REGULARDB;
return;
}
Registration works fine, validation with login seems to work but if a User logs in with his Username and Pass it won´t work.
It leads to:
Maybe somebody has a more elegant way than I have and is willing to share it or someone can give me a hint where I have a mistke.
Thank you
Niko
I had this topic quite a while ago. I would like to use several Links installations on one server with one Login (not Community).
I thought it would be a good and easy going idea to PRE and POST change database anytime user data is accessed.
Code:
$mgr->install_hooks('ONEUSERDB', [['user_login', 'PRE', 'Plugins::ONEUSERDB::user_login', '']]); $mgr->install_hooks('ONEUSERDB', [['user_signup', 'PRE', 'Plugins::ONEUSERDB::user_signup', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_validate', 'PRE', 'Plugins::ONEUSERDB::user_validate', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_validate_email', 'PRE', 'Plugins::ONEUSERDB::user_validate_email', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_pass_email', 'PRE', 'Plugins::ONEUSERDB::user_pass_email', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_valid_user', 'PRE', 'Plugins::ONEUSERDB::auth_valid_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_get_pass', 'PRE', 'Plugins::ONEUSERDB::auth_get_pass', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_get_user', 'PRE', 'Plugins::ONEUSERDB::auth_get_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_valid_session', 'PRE', 'Plugins::ONEUSERDB::auth_valid_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_create_session', 'PRE', 'Plugins::ONEUSERDB::auth_create_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_delete_session', 'PRE', 'Plugins::ONEUSERDB::auth_delete_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['init_user', 'PRE', 'Plugins::ONEUSERDB::init_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_login', 'POST', 'Plugins::ONEUSERDB::post_user_login', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_signup', 'POST', 'Plugins::ONEUSERDB::post_user_signup', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_validate', 'POST', 'Plugins::ONEUSERDB::post_user_validate', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_validate_email', 'POST', 'Plugins::ONEUSERDB::post_user_validate_email', '']]);
$mgr->install_hooks('ONEUSERDB', [['user_pass_email', 'POST', 'Plugins::ONEUSERDB::post_user_pass_email', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_valid_user', 'POST', 'Plugins::ONEUSERDB::post_auth_valid_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_get_pass', 'POST', 'Plugins::ONEUSERDB::post_auth_get_pass', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_get_user', 'POST', 'Plugins::ONEUSERDB::auth_get_user', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_valid_session', 'POST', 'Plugins::ONEUSERDB::post_auth_valid_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_create_session', 'POST', 'Plugins::ONEUSERDB::post_auth_create_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['auth_delete_session', 'POST', 'Plugins::ONEUSERDB::post_auth_delete_session', '']]);
$mgr->install_hooks('ONEUSERDB', [['init_user', 'POST', 'Plugins::ONEUSERDB::post_init_user', '']]);
Where there is the following in ONEUSERDB:
Code:
# Your code begins here. use GT::SQL;
my $ONEUSERDB = GT::SQL->new({def_path => '/path_to_oneuserdb/cgi-bin/admin/defs',cache => 1});
my $REGULARDB = GT::SQL->new({def_path => '/path_to_regular/cgi-bin/admin/defs',cache => 1});
And for any of the above subroutines:
Code:
sub user_login { $DB = $ONEUSERDB;
return;
}
sub post_user_login {
$DB = $REGULARDB;
return;
}
Registration works fine, validation with login seems to work but if a User logs in with his Username and Pass it won´t work.
It leads to:
Quote:
You must first login before you can access that.Maybe somebody has a more elegant way than I have and is willing to share it or someone can give me a hint where I have a mistke.
Thank you
Niko