UNPKG

nocobase-plugin-casdoor

Version:

Integrated Casdoor authentication system

11 lines (9 loc) 2.7 kB
/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("@nocobase/plugin-auth/client"),require("react/jsx-runtime"),require("react"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-auth/client","react/jsx-runtime","react","antd"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["nocobase-plugin-casdoor"]={},e["@nocobase/client"],e["@nocobase/plugin-auth"],e.jsxRuntime,e.react,e.antd))})(this,function(e,t,o,s,c,d){"use strict";var a=(e,t,o)=>new Promise((s,c)=>{var d=n=>{try{r(o.next(n))}catch(i){c(i)}},l=n=>{try{r(o.throw(n))}catch(i){c(i)}},r=n=>n.done?s(n.value):Promise.resolve(n.value).then(d,l);r((o=o.apply(e,t)).next())});const l=u=>{const[m,h]=c.useState(!1),g=t.useResource("casdoor"),y=()=>a(this,null,function*(){h(!0);try{const f=yield g.getAuthUrl({values:{authenticator:u.authenticator.name,redirect:new URLSearchParams(location.search?location.search.substring(1):"").get("redirect")||""}});location.href=f.data.data}finally{setTimeout(()=>{h(!1)},1e3)}});return s.jsx(d.Button,{loading:m,disabled:m,style:{width:"100%"},onClick:y,children:u.authenticator.title||u.authenticator.name})},r=()=>s.jsx(t.SchemaComponent,{schema:{type:"object",properties:{communityDingTalkAuth:{type:"void",properties:{public:{type:"object",properties:{autoSignup:{"x-decorator":"FormItem",type:"boolean",title:"用户不存在时自动注册",required:!1,"x-component":"Checkbox"}}},internal:{type:"object",properties:{emailDomain:{"x-decorator":"FormItem",type:"string",title:"邮箱域名,多个使用英文逗号分隔",required:!0,"x-component":"Input"},endpoint:{"x-decorator":"FormItem",type:"string",title:"地址",required:!0,"x-component":"Input"},clientId:{"x-decorator":"FormItem",type:"string",title:"应用ID",required:!0,"x-component":"Input"},clientSecret:{"x-decorator":"FormItem",type:"string",title:"应用秘钥",required:!0,"x-component":"Password"}}}}}}}}),i="casdoor-auth";class p extends t.Plugin{afterAdd(){return a(this,null,function*(){})}beforeLoad(){return a(this,null,function*(){})}load(){return a(this,null,function*(){this.app.pm.get(o).registerType(i,{components:{SignInButton:l,AdminSettingsForm:r}})})}}e.CasdoorPluginClient=p,e.default=p,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});