<?php $login_required = FALSE; //including necessary files include "includes/page.php"; global $path_prefix, $base_url, $network_info; require_once "{$path_prefix}/api/Message/Message.php"; require_once "{$path_prefix}/api/Invitation/Invitation.php"; $newuser = User::from_auth_token($_GET['token']); //$newuser is a User object returned by from_auth_token function if ($newuser) { //if token is valid // if user activates his account if ($_GET['action'] == 'activate') { if ($newuser->is_active == ACTIVE) { // if got verified header("Location: {$base_url}/homepage.php?msg=7015"); exit; } $activate_user = new User(); $activate_user->update_status($newuser->user_id, ACTIVE); // providing defaults to new user // creating message basic folders Message::create_basic_folders($newuser->user_id); // adding default relation if ($newuser->user_id != SUPER_USER_ID) { User_Registration::add_default_relation($newuser->user_id, $network_info); } // adding default media as well as album User_Registration::add_default_media($newuser->user_id, '', $network_info); User_Registration::add_default_media($newuser->user_id, '_audio', $network_info);
/** * Returns a user using the given authToken if the token is valid and has not * expired. Throws a PAException if the token is not valid. * @param $token * @return User object */ private function getUserFromAuthToken($authToken) { $user = null; if ($authToken != false) { // TODO: decrypt $authToken // TODO: check referer IP address try { // get username and password from authToken $user = User::from_auth_token($authToken); } catch (PAException $ex) { // redirect back to the referring URL because the token could not be authenticated // send the error message back as well //TODO: figure out what to do when the auth token cant be validated $referer = "/login.php?error=1"; if (isset($_SERVER['HTTP_REFERER'])) { $referer = $_SERVER['HTTP_REFERER']; } $message = null; if (isset($ex) && isset($ex->message)) { $message = $ex->message; } // TODO: standardise the paerror get variable and put in // AppConfig.xml as a new option $referer = $referer . "?paerror=" . $message; header("Location: {$referer}"); throw $ex; } } return $user; }
function peopleaggregator_getPersonas($args) { $user = User::from_auth_token($args['authToken']); $personas &= Persona::load_personas($user->user_id); if ($personas) { throw new PAException(INVALID_ID, "Problem loading personas for user."); } $ret = array("success" => TRUE, "personas" => $personas); }