Forum
Problem with the auth plugin example
Hi, hope I'm not being a silly billy here...
I've tried the auth plugin example as here https://docs.grabaperch.com/api/auth/ (just copied the code).
I'm getting this 500:
[Sat Feb 11 18:15:24.053810 2017] [:error] [pid 2751] [client 127.0.0.1:52366] /home/dave/sites/site1/perch/addons/plugins/auth/my_system/auth.php
[Sat Feb 11 18:15:24.094460 2017] [:error] [pid 2751] [client 127.0.0.1:52366] PHP Fatal error: Uncaught Error: Class 'my_system_auth_plugin' not found in /home/dave/sites/site1/perch/core/lib/PerchUsers.class.php:27\nStack trace:\n#0 /home/dave/sites/site1/perch/core/inc/auth.php(17): PerchUsers->get_current_user()\n#1 /home/dave/sites/site1/perch/core/index.php(14): include('/home/dave/site...')\n#2 /home/dave/sites/site1/perch/index.php(3): include('/home/dave/site...')\n#3 {main}\n thrown in /home/dave/sites/site1/perch/core/lib/PerchUsers.class.php on line 27
I believe I've faithfully copied the example. As far as I can tell from the code, perch/core/inc/auth.php
and perch/core/lib/PerchUsers.class.php
look in difference places for the plugin class -one with addons
in the path and other not -so I've put the my_system/auth.php
in both places to see if that helps but it didn't.
Thanks for any thoughts
Does your app include an autoloader?
I'm afraid I don't know what that is, so I suppose not.
Is your class declared as
my_system_auth_plugin
?Yes. At present I have two of the same file, both with that class declaration, copied from the example, one in
/home/dave/sites/site1/perch/addons/plugins/auth/my_system/auth.php
and one in/home/dave/sites/site1/perch/plugins/auth/my_system/auth.php
I've tried one and then the other and both.
What I've done (just for now) is paste that class into the top of
/home/dave/sites/site1/perch/core/lib/PerchUsers.class.php
, which gives me the expected result in that no login is required. (Although the class is printed at the top of the admin page).Easier, and leaving you with support, would be to just add it to your
config.php
file.OK thanks. I've deleted
auth
folder from/home/dave/sites/site1/perch/plugins
. (Had that there just to try it). Also deleted the classmy_system_auth_plugin
from/home/dave/sites/site1/perch/core/lib/PerchUsers.class.php
.So I have
/home/dave/sites/site1/perch/addons/plugins/auth/my_system
containingauth.php
containing the example code with a class ofmy_system_auth_plugin
, and the last two lines ofconfig.php
are:The 500 I'm getting logs as:
[Sun Feb 12 15:30:25.427135 2017] [:error] [pid 4010] [client 127.0.0.1:41266] PHP Warning: require(/home/dave/sites/site1/perch/plugins/auth/my_system/auth.php): failed to open stream: No such file or directory in /home/dave/sites/site1/perch/core/lib/PerchUsers.class.php on line 24 [Sun Feb 12 15:30:25.512821 2017] [:error] [pid 4010] [client 127.0.0.1:41266] PHP Fatal error: require(): Failed opening required '/home/dave/sites/site1/perch/plugins/auth/my_system/auth.php' (include_path='.:/usr/share/php') in /home/dave/sites/site1/perch/core/lib/PerchUsers.class.php on line 24
Can you show us your
auth.php
file?Sure:
/home/dave/sites/site1/perch/addons/plugins/auth/my_system/auth.php
Can I see your diagnostics report?
Sure, I'm working with another dev (who bought the licence) and not sure if I should show the domain, so have hidden:
Hosting settings
On the off chance it's somehow related: if I move a file
about.html
in site root toabout/index.php
, I can't view the About page by browsing 'about/' -I have to go to 'about/index.php'. (I'm new to all this :)It might be worth checking with your colleague - I can't see why that class would not be available if the
require
doesn't fail.Wait, that's not the whole of your
auth.pho
file is it? It has a<?php
tag too, right?Um, it didn't exactly have one. I feel like a real silly billy. (massive PHP noob error)
Thank you very much for your help :)