forked from thathoff/kirby-oauth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 3.77 KB
/
index.js
1
(function () {function d(o,e){var n=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})),n.push.apply(n,t)}return n}function f(o){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?d(Object(n),!0).forEach(function(e){h(o,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(n,e))})}return o}function h(o,e,n){return e in o?Object.defineProperty(o,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):o[e]=n,o}function g(t,e,r,n,a,o,u){try{var s=t[o](u),i=s.value}catch($){return void r($)}s.done?e(i):Promise.resolve(i).then(n,a)}function j(t){return function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function u(t){g(o,n,a,u,s,"next",t)}function s(t){g(o,n,a,u,s,"throw",t)}u(void 0)})}}var c={name:"OAuth",props:{providers:{type:Array,default:function(){return[]}},error:{type:String,default:null}},computed:{providersForList:function(){return this.providers.map(function(t){return{id:t.id,class:"thathoff-oauth-provider-".concat(t.id),text:t.name,link:t.href,target:"_self",flag:{icon:"check",link:t.href,target:"_self"}}})}}};if(typeof c==="function"){c=c.options}Object.assign(c,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"thathoff-oauth-providers"},[_vm.error!==null?_c("div",{staticClass:"k-login-alert k-login-alert--oauth",on:{"click":function($event){_vm.error=null}}},[_c("span",[_vm._v(_vm._s(_vm.error))]),_vm._v(" "),_c("k-icon",{attrs:{"type":"alert"}})],1):_vm._e(),_vm._v(" "),_c("k-field",{attrs:{"name":"oauth","label":"Sign in with"}},[_c("k-list",{attrs:{"items":_vm.providersForList}})],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:"data-v-bd33c6",functional:undefined}}());var b={components:{"k-login-form":null,OAuth:c},data:function(){return{settings:{},providers:[],error:null}},created:function(){this.load()},methods:{load:function(){var t=this;return j(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.$api.get("oauth/settings");case 2:return t.settings=e.sent,e.t0=Object,e.next=6,t.$api.get("oauth/providers");case 6:return e.t1=e.sent,t.providers=e.t0.values.call(e.t0,e.t1),e.next=10,t.$api.get("oauth/oauthError");case 10:t.error=e.sent.msg;case 11:case"end":return e.stop();}},e)}))()}}};if(typeof b==="function"){b=b.options}Object.assign(b,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_vm.settings.enabled===false||_vm.settings.onlyOauth===false?_c("k-login-form"):_vm._e(),_vm._v(" "),_vm.settings.enabled===true?_c("OAuth",{attrs:{"providers":_vm.providers,"error":_vm.error}}):_vm._e()],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("thathoff/oauth",{created:function(){var o,e,n,t,r,i;"/installation"===(null===(o=panel)||void 0===o?void 0:null===(e=o.app)||void 0===e?void 0:null===(n=e.$route)||void 0===n?void 0:n.path)&&panel.app.$go("/"),null===(t=panel)||void 0===t||null===(r=t.app)||void 0===r||null===(i=r.$router)||void 0===i||i.beforeEach(function(o,e,n){"/installation"!==o.path&&n()})},use:[{install:function(o){var e=o.options.components["k-login-view"].options.components["k-login-form"];b.components["k-login-form"]=e,o.options.components["k-login-view"].options.components=f(f({},o.options.components["k-login-view"].options.components),{},{"k-login-form":b})}}]});})();