Jump to content

Orkun

Members
  • Content Count

    256
  • Joined

  • Last visited

Community Reputation

79 Excellent

About Orkun

  • Rank
    Sr. Member
  • Birthday 10/10/1996

Profile Information

  • Gender
    Male
  • Location
    Switzerland

Recent Profile Visitors

4,302 profile views
  1. Looks like this happens only when the ckeditor field is in inline mode. In regular mode the images added at the position where my cursor is. Is this a expected behavior or a bug? KR Orkun
  2. Hi Guys When I try to add an Image inside the CKEditor Field, that Image always gets added to the TOP instead there where the cursor was. Do you know why this problem happens? KR Orkun
  3. Hi @thomasaull Do you know what the best way is to restrict the API Requests for specific IP Adresses? KR Orkun
  4. Hi @kongondo Is it normal that the folder in /site/assets/MediaManager/jqfu/.files_no_show/ is full of files/duplicate files? We can't upload any files anymore, because we are getting the error of duplicate media page (empty file upload result). It looks like he tries to create a page from a file from the .files_no_show folder but that page with the name already exists. Isn't the /site/assets/MediaManager/jqfu/.files_no_show/ just a temporary folder? Shouldn't be the file deleted after the media page was created? KR Orkun
  5. Hi all I found a tool which "fixed" the mp3 file so that I could upload it again in media manager. I used the tool https://www.deepniner.net/mp3trimmer/, but it also works with the https://audiotrimmer.com/ online tool. I think it removes all non-audio data from the mp3 file. KR Orkun
  6. @kongondo Any news on this? What I could do is, is to add the "application/octet-stream" mimetype for mp3 extensions. I could do this inside the method "mimeTypes" of the File "MediaManagerUtilities.php" but don't know if this is a good Idea. KR Orkun
  7. Hi @kongondo We have a problem with uploading some mp3 files. We can't upload a specific .mp3 file in the media manager because on the server it returns application/octet-stream as mime-type instead of audio/mpeg. But when I check with finfo or mime_content_type on a localhost it returns audio/mpeg mimetype. Even when I check the mime-type on the mac osx terminal (file --mime-type -b filename) it returns audio/mpeg. What should I do? I also can't find an online tool where the customer could repair the mp3 file or something. I downloaded the file from the dropbox account/link of the customer. The funny thing is, when i convert that mp3 file to wav it can be uploaded. KR Orkun
  8. Hi @Craig A Rodway Ok thank you very much! I have made now a function called ssoLogin() and place the hook inside /site/ready.php: function ssoLogin() { if(!wire('user')->isLoggedin()) { $token = wire('input')->get('token'); // If not token, show error? try { $decoded = JWT::decode($token, wire('modules')->RestApi->jwtSecret, array('HS256')); } catch (\Exception $e) { // Error parsing/decoding token - do not accept. Show error/redirect. } // print_r($decoded); // Find user based on supplied email. // Use other PW user fields or properties from JWT as necessary. $u = wire('users')->get('email=' . wire('sanitizer')->selectorValue($decoded->claims->email)); if ( ! $u->id) { // Could not find user - don't exist. // Could create them at this point, if you have enough detail in the JWT to do so. } // Force user login return wire('session')->forceLogin($u); } return false; } // Inside /site/ready.php $this->addHookAfter('PageRender::renderPage', function(HookEvent $event) { if (strpos($_SERVER['REQUEST_URI'], $this->wire('config')->urls->admin) === 0 || $this->wire('page')->template->name == 'admin') return; ssoLogin(); }); KR Orkun
  9. Hi @Craig A Rodway Thank you very much! I tested it and it works great. One question though, where would you place the code above? I placed it for the moment inside the _init.php because it is prepend for every template. KR Orkun
  10. Hi Guys We are trying to build a Login Mask (with Node.js) which should act as a single sign on for two websites. The first website is a angular project on firebase the other one is processwire. We are trying to achieve the project with JWTs (Json Web Tokens). My Question is how can I make a user be loggedin in processwire with a JWT? Has someone experiences with this?
  11. Hi @thomasaull As you can see in the second & third screenshot above, I am already setting it in Postman. But perhaps I could try it with a js file localy. Another question. How would you save the JWT Token after you have get it from the /api/auth endpoint? Cookie? Local Storage? DB? I mean after I got the JWT Token i need to set it for every other API Request inside the Header and for that I need to somehow save it somewhere, am I right? KR Orkun
  12. It still gives the same error
  13. Hi @thomasaull Thank you for your input. I choosed the POST Request way. Routes.php <?php require_once wire('config')->paths->RestApi . "vendor/autoload.php"; require_once wire('config')->paths->RestApi . "RestApiHelper.php"; require_once __DIR__ . "/Users.php"; $routes = [ 'searchuser' => [ ['OPTIONS', '', RestApiHelper::class, 'preflight'], // this is needed for CORS Requests ['POST', '', Handler\Users::class, 'searchByEmail'], ], ]; Users.php <?php namespace Handler; class Users { public static function searchByEmail($data){ $data = \RestApiHelper::checkAndSanitizeRequiredParameters($data, ['email|email']); $response = new \StdClass(); if($data->email != "") { $user = wire('users')->get("template=user, email=$data->email"); if(!$user->id) throw new \Exception('user not found'); $response->id = $user->id; $response->name = $user->name; $response->email = $user->email; } else { throw new \Exception('Unvalid E-Mail address'); } return $response; } } But now I have other Problem with JWT Auth. I activated the JWT Option inside the Module Settings and remove the ["auth" => false] part from the routes (as you can see above). And when I test in Postman it always gives me the error "No Authorization Header found" even when the Auth Header is set. Step1: Getting JWT Token Step 2: Saving JWT Token to a Postman Global Variable Step 3: Set the new "JWT" Global variable as Auth Header for the actual POST Request (searchbymail) Step 4: Make POST Request: Search after User with E-Mail What I am doing wrong? KR Orkun
  14. Hi @thomasaull Thank you for this great module! I came across a problem. I need an endpoint where I can search after an user with his e-mail address. So I created a new grouped Route. My Routes.php looks like this: <?php require_once wire('config')->paths->RestApi . "vendor/autoload.php"; require_once wire('config')->paths->RestApi . "RestApiHelper.php"; require_once __DIR__ . "/Example.php"; $routes = [ ['OPTIONS', 'test', RestApiHelper::class, 'preflight', ['auth' => false]], // this is needed for CORS Requests ['GET', 'test', Example::class, 'test'], 'searchuser' => [ ['OPTIONS', '', RestApiHelper::class, 'preflight', ['auth' => false]], // this is needed for CORS Requests ['GET', '{email}', Example::class, 'doesUserWithEmailExist', ['auth' => false]], ], 'users' => [ ['OPTIONS', '', RestApiHelper::class, 'preflight', ['auth' => false]], // this is needed for CORS Requests ['GET', '', Example::class, 'getAllUsers', ["auth" => false]], ['GET', '{id:\d+}', Example::class, 'getUser', ["auth" => false]], // check: https://github.com/nikic/FastRoute ], ]; My Function in Example.php looks like this: public static function doesUserWithEmailExist($data){ echo "<pre>"; echo print_r($data, true); echo "</pre>"; $data = RestApiHelper::checkAndSanitizeRequiredParameters($data, ['email|email']); $response = new \StdClass(); if($data->email != "") { $user = wire('users')->get("template=user, email=$data->email"); if(!$user->id) throw new \Exception('user not found'); $response->test = $data->email; $response->id = $user->id; $response->name = $user->name; $response->email = $user->email; } else { throw new \Exception('Unvalid E-Mail address'); } return $response; } When calling from Browser: The Problem is, that the "@" character in the E-Mail gets stripped away and therefore the email is always wrong. I investigated this and found out, that it is because of the wire('input')->url codepart on line 61 in the Router.php. This is stripping away the "@" character when calling. When I replace the wire('input')->url part with $_SERVER['REQUEST_URI'] it is working. What should I do? KR Orkun
  15. I have solved this now with a second find since it are not much pages (102 since website launch in 2016). // Workaround $specificSpecialitiesFilteredByClinic = $pages->find("template=specialities-clinics, sort=title, choose_sender_2016={$rootParent->choose_sender_2016}"); $ids = ""; foreach($specificSpecialitiesFilteredByClinic as $speciality){ $ids .= $speciality->parent->id."|"; } $ids = rtrim($ids, "|"); $find = $pages->find("id=$ids, sort=title, limit=24"); KR Orkun
×
×
  • Create New...