diff --git a/cms/static/js/qcms/qcms-login.js b/cms/static/js/qcms/qcms-login.js new file mode 100644 index 0000000..25ea4d9 --- /dev/null +++ b/cms/static/js/qcms/qcms-login.js @@ -0,0 +1,87 @@ +if(!qcms){ + var qcms = {} +} + +qcms.login = {model:null} +qcms.login.authenticate = function (){ + var _id = qcms.login.model + if (_id.match(/^oauth2/i)){ + ; + }else{ + var _args = qcms.login.get() + var http = HttpClient.instance() + http.setHeader('Content-Type','application/json') + http.setHeader('method',_id) + http.setData( JSON.stringify(_args)) + var _uri = ([qcms.context,'/login']).join('') + http.post(_uri,(x)=>{ + + if(x.readyState == 4 && x.status == 200){ + + window.open(x.responseURL,'_self'); + }else{ + $('.qcms-login-error').slideDown() + } + }) + + } + + +} +qcms.login.get = function (){ + var _args = {} + var _nodes = $('.qcms-login-input INPUT') + _nodes.each((_index)=>{ + var _key = $(_nodes[_index]).attr('class') + var _value = $(_nodes[_index]).val() + _args[_key] = _value + }) + return _args +} +qcms.login.cancel = function (){ + var _nodes = $('.qcms-login-input INPUT') + _nodes.each((_index)=>{ + $(_nodes[_index]).val('') + }) + $('.qcms-login-error').slideUp() +} +/** + * PAM authentication + */ + +// qcms.authenticate = {} +// qcms.authenticate.nextcloud = function (){ +// var _uri = ([qcms.context,'/login']).join('') +// _args = qcms.login.get() + +// var http = HttpClient.instance() +// http.setHeader('Content-Type','application/json') +// // http.setHeader('method','pam') +// http.setData( JSON.stringify(_args)) +// http.post(_uri,(x)=>{ +// if(x.readyState == 4 && x.status == 200){ + +// } +// }) + +// } +// qcms.authenticate.pam = function (){ +// var _uri = ([qcms.context,'/login']).join('') +// var _args = { +// username:$('.qcms-login-input .username').val(), +// password:$('.qcms-login-input .password').val() +// } + +// var http = HttpClient.instance() +// http.setHeader('Content-Type','application/json') +// http.setHeader('method','pam') +// http.setData( JSON.stringify(_args)) +// http.post(_uri,(x)=>{ + +// if(x.readyState == 4 && x.status == 200){ + +// window.open(x.responseURL,'_self') +// ; +// } +// }) +// } \ No newline at end of file