Last active
August 29, 2015 13:59
-
-
Save rpip/10604477 to your computer and use it in GitHub Desktop.
Expose Zotonic authentication via a REST API service. This example is built for use with phpBB authentication as documented here: https://wiki.phpbb.com/Authentication_plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(service_phpbb_auth). | |
-svc_title("External Zotonic Authentication service"). | |
%% You can change this to restrict access | |
-svc_needauth(false). | |
-export([process_get/2]). | |
-include_lib("zotonic.hrl"). | |
process_get(_ReqData, Ctx) -> | |
Username = z_context:get_q("username",Context), | |
Password = z_context:get_q("password",Context), | |
Response = case z_auth:logon_pw(Username, Password, Ctx) of | |
{context, _Ctx1} -> | |
{success, true}; | |
{false, _Ctx2} -> | |
{success, false} | |
end, | |
z_convert:to_json(Response). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place this script in the
services
folder in the module or site and access it at http://localhost:8000/api/phpbb/auth