Hi, i'm now messing with the user system of ossn. I need to execute some code (verifications on a microservice API) defined in a component when a user triggers the following events :
I opened the adequate files from ossn/actions/user/ and checked if any callback were declared in there but only the login file triggers a callback :
#user/login.php
ossn_trigger_callback('login', 'success', $vars);
I'd like to be able to detect these events and execute code (mainly to LOG and add a JWT with permissions generated from my micro-service). I could add code to these files to trigger callbacks but i know you don't recommend modifying the core of ossn so i'm looking for an alternate way.
you may can do following
$user = ossn_user_by_guid($vars['user']->guid);
Still working on my identity manager, i managed the registration part with the hook you provided.
I am now working on the login hook in OssnUser.php, It seems the user's password is not passed along with the object to the hook :
In the public function Login() i can read :
unset($user->password);
unset($user->salt);
OssnSession::assign('OSSN_USER', $user);
$this->update_last_login();
$vars = array();
$vars['user'] = $user;
$login = ossn_call_hook('user', 'login', $vars, true);
return $login;
And from inside a hook function i wrote, when i print_r the $vars array i get :
[HOOK]user
[TYPE]login
[RETURNVALUE]1
[PARAMS]Array
(
[user] => OssnUser Object
(
[guid] => 1
[type] => admin
[username] => BobMoran
[email] => [email protected]
[first_name] => Bob
[last_name] => Moran
[last_login] => 1571037608
[last_activity] => 1571037684
[activation] =>
[time_created] => 1571037602
[fullname] => Adrien Allemand
[birthdate] => 08/08/1908
[gender] => male
[data] => stdClass Object
(
)
)
)
I need access to that password to plugin my identification manager. Is there a nicer way than selecting it from DB in my hook ?
Yes you may stop user creation.
ossn_add_hook('user', 'create', 'disable_user_create');
function disable_user_create(){
return false;
}
Is there a way to prevent user creation/modification from the callbacks ? I need to prevent user creation if my microservice doesn't respond or raises an exception. I am thinking of a hook of some sort able to stop the user creation or update process ossn-side ?
ok thanks !
For registration you may use
ossn_register_callback('user', 'created', 'my_callback_abc');
For others you may use callback that arises before the action is performed,
ossn_register_callback('action', 'load', 'my_action_callback');
function my_action_callback($callback, $type, $vars){
if($vars['action'] == 'resetlogin'){
//
}
}
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)