Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Single signon with Moodle
rightsideup
New
Hello all, In case you don't know, the moodle forums are very basic with little structure or control, so I've set up Vanilla to display embedded in the Moodle site - all working fine.
What I'm struggling with is implementing a single sign on via the existing site. I've read the jsConnect page here but, since I have a fairly basic understanding of how these things work, I'm unsure what I actually need to do.
I'd really appreciate any pointers on where functions.jsconnect.php and index.php need to go. Vanilla forums is hosted at a different domain to the Moodle site at the moment although that will probably change in time.
Thanks in advance...
0
Comments
I think that the easiest way would be developing a Moodle plugin for it.
My shop | About Me
Sadly that's well outside my capabilities!!
I would probably be able to develop a Moodle plugin, but, unfortunately, my list is full at the moment. I can take note of it and, eventually, see what I can do when I'll have some spare time.
My shop | About Me
Now that would be fabulous - thanks! In the meantime I'll keep tinkering.
We have just downloaded Vanilla and are exploring ways to connect it to our Moodle courses. Have either of you learned anything since you last posted here? Still no plugins available on Moodle, as far as I know. But someone did develop a plugin for Vanilla that creates an LTI connection. Not exactly sure how that works with Moodle -- but there's a post in the Moodle forums about it here.
I haven't looked at it yet, due to other commitments. The logic itself is not too complicated, but I would have to learn how to transform it into a Moodle plugin.
My shop | About Me
Well, believe it or not, I'm still struggling with this. Since my last post I've installed Vanilla on the same server as my Moodle install, I have jsconnect installed and properly (I think) configured and have functions.jsconnect.php and index.php (the latter renamed to sso.php) in the root web directory.
My sso.php looks like this:
When I test the jsConnect settings in the dashboard I get:
test({"email":"","name":"","photourl":"","uniqueid":"","client_id":"1234567890","signature":"370e258aabff177244f19b4dfca0d630"})
so it's clearly not picking up the id, username and email?
My head is about to explode! Please can anybody spot what I'm doing wrong?
Thanks
Lines 18-21: is $USER declared? Add
var_dump($USER);
before the conditional to see if it is.Line 24:
4. Generate the jsConnect string.
should be commented or removed.Add Pages to Vanilla with the Basic Pages app
Line 24 is commented out, cut and paste went wrong - fixed above!
I really am a beginner at all of this, do you mean
var_dump($USER);
should go in after line 16?It can go anywhere within the lines that you pasted and preferably on line 15, which is before the if statement.
Add Pages to Vanilla with the Basic Pages app
You need to get the Moodle session and use that to fill out the $USER object.
EDIT: It looks like Moodle stores the user object in a super global. Try adding
global $USER;
to the top of your file (after the initial PHP tag). SOURCESearch first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Tried adding
global $USER;
but still the same output from 'test connection' - any other ideas?Try putting this before your global user line:
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Just tried this and test connection is displaying NULL followed by the previous (empty) output?
Nothing displaying at all - v frustrating!
It's confirmed that $USER isn't declared. You need to retrieve the user session object as $USER from Moodle and require it in your script as @hgtonight said.
Add Pages to Vanilla with the Basic Pages app
The snag is that I'm stumbling about here and don't really understand how to do that.
Put this at the top of your script on a new line under
<?php
and replace the path in the require statement to the config.php file of your Moodle install:Then do this: https://moodle.org/mod/forum/discuss.php?d=187465#yui_3_9_1_2_1377796314235_261
Add Pages to Vanilla with the Basic Pages app
You're a star!! All working fine now - excellent.
For some reason, the '/path/to/moodleconfig/config.php' needed to be the absolute path on the server not just a relative one which is what I tried when you first suggested it.
I'll post up the config files tomorrow in case anybody else runs into the same problem.
Once again, many thanks.
No problem! Thanks to @hgtonight for actually finding the link for the solution!
Add Pages to Vanilla with the Basic Pages app