Add the following script to your HTML file to indicate if the user is logged in and also to the allow the user to sign off. You can almost literally copy and paste your rules from one to the other - saving precious time. One of the nicer features of the script is that it goes hand in hand with a sister script - the PHP Validation script which works very similarly. for this test, simply print that the authentication was successfullĤ. This small but powerful script lets you add javascript validation to your forms quickly and with very little effort. and the user's login name can be read with phpCAS::getUser(). at this step, the user has been authenticated by the CAS server VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL! THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION. For quick testing you can disable SSL validation of the CAS server. phpCAS::setCasServerCACert($cas_server_ca_cert_path) on the CAS server and uncomment the line below For production use set the CA certificate that is the issuer of the cert PhpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context) '/CAS.php' /*This is the path that to the CAS directory on your server, not the URL*/
require_once 'config.php' /*commented out by Donny*/ Load the settings from the central config file
The following script is based on a simple CAS client: If you want to make the entire site private, just add the script to an include file in the header. I strongly suggest that you learn more about properly controlling MODx form validation, and selectively disabling that validation for things like the part. php file that you want the contents to be private. Place the following codes in at the top of any. Place the entire phpCAS directory on your server.ģ. You don’t need to create separate accounts for the site.Ģ.
For example, if you have a career services web site and you only want students to access the materials using their email (university) credentials, this script would do the trick. Hopefully this helps you deliver some AJAX goodness to your forms.The following script makes a private web site accessible only to authenticated users. You can find a usage example at the PR on Github but essentially you want to include these properties in your FormIt call: &validationErrorBulkFormatJson=`1` Note: the official docs for FormIt are here: How It Works I submitted a PR that the fine folks at Sterc kindly reviewed and merged-along with important security-related patches by other awesome MODX community members.
Well as of FormIt version 2.2.10, there's an easier way. You can customize most, if not all, the output, but that's overriding a lot of Chunks, and you have to call an output modifier on every placeholder to ensure the value is escaped for JSON. The really annoying part is that the error messages don't come in JSON-often they're wrapped in HTML actually. You pretty much have to format the JSON in a tpl Chunk and insert the values via FormIt placeholders. HrmphĪs it turns out, it's a bit of a slog to get FormIt to respond with JSON. Your JS will POST the form to that Resource, and then you probably want it to return JSON so you can pass any errors and messages back to the user in the browser. You can do this in MODX by setting up a dedicated Resource that calls the FormIt Snippet. Your website haz formz but you wanna do it all fancy with AJAX.