/** * @method POST */ function add() { // get token $token = Utilities::ValidateJWTToken(); // check if token is not null if ($token != NULL) { parse_str($this->request->data, $request); // parse request $userId = $request['userId']; $photoUrl = $request['photoUrl']; $user = User::EditPhoto($userId, $photoUrl); // build full photo url $site = Site::GetBySiteId($token->SiteId); // set images URL $imagesURL = $site['Domain']; $fullPhotoUrl = $imagesURL . '/files/thumbs/' . $photoUrl; // return a json response $response = new Tonic\Response(Tonic\Response::OK); $response->contentType = 'text/html'; $response->body = $fullPhotoUrl; return $response; } else { // unauthorized access return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }
/** * @method POST */ function add() { // get token $token = Utilities::ValidateJWTToken(apache_request_headers()); // check if token is not null if ($token != NULL) { parse_str($this->request->data, $request); // parse request $userId = $request['userId']; $photoUrl = $request['photoUrl']; $user = User::EditPhoto($userId, $photoUrl); // build full photo url $site = Site::GetBySiteId($token->SiteId); // set images URL if (FILES_ON_S3 == true) { $bucket = $site['Bucket']; $imagesURL = str_replace('{{bucket}}', $bucket, S3_URL); $imagesURL = str_replace('{{site}}', $site['FriendlyId'], $imagesURL); } else { $imagesURL = $site['Domain']; } $fullPhotoUrl = $imagesURL . '/files/thumbs/' . $photoUrl; // return a json response $response = new Tonic\Response(Tonic\Response::OK); $response->contentType = 'text/html'; $response->body = $fullPhotoUrl; return $response; } else { // unauthorized access return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }
/** * @method POST */ function add() { // get an authuser $authUser = new AuthUser(); if (isset($authUser->UserUniqId)) { // check if authorized parse_str($this->request->data, $request); // parse request $userUniqId = $request['userUniqId']; $photoUrl = $request['photoUrl']; $user = User::EditPhoto($userUniqId, $photoUrl); // update the user in session $authUser->UpdateUser(); // return a json response $response = new Tonic\Response(Tonic\Response::OK); $response->contentType = 'application/json'; return $response; } else { // unauthorized access return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }