2023-10-02 06:44:14 +08:00
|
|
|
(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e),t.d(e,{extend:()=>l});const o=flarum.core.compat["common/extenders"];var n=t.n(o);function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,i(t,e)}const a=flarum.core.compat["common/Model"];var s=t.n(a),c=function(t){function e(){for(var e,o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).client_id=s().attribute("client_id"),e.client_secret=s().attribute("client_secret"),e.redirect_uri=s().attribute("redirect_uri"),e.grant_types=s().attribute("grant_types"),e.scope=s().attribute("scope"),e.user_id=s().attribute("user_id"),e.client_name=s().attribute("client_name"),e.client_icon=s().attribute("client_icon"),e.client_desc=s().attribute("client_desc"),e.client_home=s().attribute("client_home"),e}return r(e,t),e}(s()),u=function(t){function e(){for(var e,o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).scope=s().attribute("scope"),e.resource_path=s().attribute("resource_path"),e.method=s().attribute("method"),e.is_default=s().attribute("is_default"),e.scope_name=s().attribute("scope_name"),e.scope_icon=s().attribute("scope_icon"),e.scope_desc=s().attribute("scope_desc"),e}return r(e,t),e}(s());const l=[(new(n().Store)).add("oauth-clients",c).add("oauth-scopes",u)],p=flarum.core.compat["forum/app"];var d=t.n(p);const h=flarum.core.compat["common/extend"],f=flarum.core.compat["forum/components/UserPage"];var _=t.n(f);flarum.core.compat["common/components/LinkButton"],flarum.core.compat["common/components/Page"];const y=flarum.core.compat["forum/components/IndexPage"];var b=t.n(y);const v=flarum.core.compat["forum/components/LogInModal"];var g=t.n(v);const x=flarum.core.compat["common/utils/extractText"];var z=t.n(x);const O=flarum.core.compat["common/components/Tooltip"];var w=t.n(O);const k=flarum.core.compat["common/components/Button"];var P=t.n(k),j=function(t){function e(){for(var e,o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).params=[],e.client=null,e.scopes=null,e.client_scope=[],e.loading=!0,e.is_authorized=!1,e.submit_loading=!1,e}r(e,t);var o=e.prototype;return o.oninit=function(e){var o=this;t.prototype.oninit.call(this,e),d().session.user||setTimeout((function(){return d().modal.show(g())}),500);var n=m.route.param();null==n.client_id||null==n.response_type||null==n.redirect_uri?m.route.set("/"):(this.params=n,d().store.find("oauth-clients",n.client_id).then((function(t){if(0===t.length)m.route.set("/");else{o.client=t[0];var e=null;e=o.client.redirect_uri().indexOf(" ")>-1?o.client.redirect_uri().split(" "):[o.client.redirect_uri()],d().forum.attribute("foskym-oauth-center.require_exact_redirect_uri")&&-1==e.indexOf(n.redirect_uri)&&m.route.set("/"),d().forum.attribute("foskym-oauth-center.allow_implicit")||"token"!=n.response_type||m.route.set("/"),d().forum.attribute("foskym-oauth-center.enforce_state")&&null==n.enforce_state&&m.route.set("/"),d().store.find("oauth-scopes").then((function(t){o.scopes=t;var e=n.scope;null==n.scope&&(e=o.client.scope());var i=[];i=null==e?[]:e.indexOf(" ")>-1?e.split(" "):[e];var r=[];o.scopes.map((function(t){var e=i.indexOf(t.scope());e>-1?i[e]=t:i.slice(e,1),1===t.is_default()&&r.push(t)})),i=i.concat(r),o.client_scope=i.filter((function(t,e){return i.indexOf(t)===e})),console.log(o.client_scope),o.loading=!1,m.redraw()}))}})))},o.setTitle=function(){d().setTitle(z()(d().translator.trans("foskym-oauth-center.forum.page.tit
|