Compare commits

..

6 Commits

Author SHA1 Message Date
Yang Luo
1ab7a54133 Add DefaultApplication to conf 2023-07-02 09:15:22 +08:00
Yang Luo
0e2dad35f3 Improve OrganizationSelect width 2023-06-30 02:04:44 +08:00
Yang Luo
d31077a510 Remove conf values 2023-06-30 01:38:48 +08:00
Denis Plynskiy
eee9b8b9fe feat: add organization context select box for admin (#2013)
* feat: organization as context

* feat: organization as context with backend filtration

* Update app.conf

* update app.conf and hide organization select for mobile.

---------

Co-authored-by: dplynsky <dplynsky@ptsecurity.com>
Co-authored-by: hsluoyz <hsluoyz@qq.com>
2023-06-30 01:32:34 +08:00
Baihhh
91cb5f393a fix: fix Swagger docs page (#2025)
Signed-off-by: baihhh <2542274498@qq.com>
2023-06-30 00:48:39 +08:00
haiwu
807aea5ec7 feat: add tags to application (#2027)
* feat: add tags to application

* fix: fix for merge master

* feat: update i18n(backend&frontend) for application tags
2023-06-30 00:04:12 +08:00
72 changed files with 1053 additions and 218 deletions

View File

@@ -69,6 +69,15 @@ func (c *ApiController) HandleLoggedIn(application *object.Application, user *ob
return
}
// check user's tag
if !user.IsGlobalAdmin && !user.IsAdmin && len(application.Tags) > 0 {
// only users with the tag that is listed in the application tags can login
if !util.InSlice(application.Tags, user.Tag) {
c.ResponseError(fmt.Sprintf(c.T("auth:User's tag: %s is not listed in the application's tags"), user.Tag))
return
}
}
if form.Password != "" && user.IsMfaEnabled() {
c.setMfaSessionData(&object.MfaSessionData{UserId: userId})
resp = &Response{Status: object.NextMfa, Data: user.GetPreferredMfaProps(true)}
@@ -238,7 +247,7 @@ func isProxyProviderType(providerType string) bool {
// @Param code_challenge_method query string false code_challenge_method
// @Param code_challenge query string false code_challenge
// @Param form body controllers.AuthForm true "Login information"
// @Success 200 {object} Response The Response object
// @Success 200 {object} controllers.Response The Response object
// @router /login [post]
func (c *ApiController) Login() {
resp := &Response{}

View File

@@ -28,7 +28,7 @@ import (
// @param owner form string true "owner of user"
// @param name form string true "name of user"
// @param type form string true "MFA auth type"
// @Success 200 {object} The Response object
// @Success 200 {object} controllers.Response The Response object
// @router /mfa/setup/initiate [post]
func (c *ApiController) MfaSetupInitiate() {
owner := c.Ctx.Request.Form.Get("owner")

View File

@@ -37,6 +37,7 @@ func (c *ApiController) GetOrganizations() {
value := c.Input().Get("value")
sortField := c.Input().Get("sortField")
sortOrder := c.Input().Get("sortOrder")
organizationName := c.Input().Get("organizationName")
isGlobalAdmin := c.IsGlobalAdmin()
if limit == "" || page == "" {
@@ -73,7 +74,7 @@ func (c *ApiController) GetOrganizations() {
}
paginator := pagination.SetPaginator(c.Ctx, limit, count)
organizations, err := object.GetMaskedOrganizations(object.GetPaginationOrganizations(owner, paginator.Offset(), limit, field, value, sortField, sortOrder))
organizations, err := object.GetMaskedOrganizations(object.GetPaginationOrganizations(owner, organizationName, paginator.Offset(), limit, field, value, sortField, sortOrder))
if err != nil {
c.ResponseError(err.Error())
return

View File

@@ -71,7 +71,7 @@ func (c *ApiController) GetPricings() {
// @Tag Pricing API
// @Description get pricing
// @Param id query string true "The id ( owner/name ) of the pricing"
// @Success 200 {object} object.pricing The Response object
// @Success 200 {object} object.Pricing The Response object
// @router /get-pricing [get]
func (c *ApiController) GetPricing() {
id := c.Input().Get("id")

View File

@@ -42,6 +42,7 @@ func (c *ApiController) GetRecords() {
value := c.Input().Get("value")
sortField := c.Input().Get("sortField")
sortOrder := c.Input().Get("sortOrder")
organizationName := c.Input().Get("organizationName")
if limit == "" || page == "" {
records, err := object.GetRecords()
@@ -54,6 +55,9 @@ func (c *ApiController) GetRecords() {
c.ServeJSON()
} else {
limit := util.ParseInt(limit)
if c.IsGlobalAdmin() && organizationName != "" {
organization = organizationName
}
filterRecord := &object.Record{Organization: organization}
count, err := object.GetRecordCount(field, value, filterRecord)
if err != nil {

View File

@@ -71,7 +71,7 @@ func (c *ApiController) GetSubscriptions() {
// @Tag Subscription API
// @Description get subscription
// @Param id query string true "The id ( owner/name ) of the subscription"
// @Success 200 {object} object.subscription The Response object
// @Success 200 {object} object.Subscription The Response object
// @router /get-subscription [get]
func (c *ApiController) GetSubscription() {
id := c.Input().Get("id")

View File

@@ -66,7 +66,7 @@ func (c *ApiController) WebAuthnSignupBegin() {
// @Tag User API
// @Description WebAuthn Registration Flow 2nd stage
// @Param body body protocol.CredentialCreationResponse true "authenticator attestation Response"
// @Success 200 {object} Response "The Response object"
// @Success 200 {object} controllers.Response "The Response object"
// @router /webauthn/signup/finish [post]
func (c *ApiController) WebAuthnSignupFinish() {
webauthnObj, err := object.GetWebAuthnObject(c.Ctx.Request.Host)
@@ -150,7 +150,7 @@ func (c *ApiController) WebAuthnSigninBegin() {
// @Tag Login API
// @Description WebAuthn Login Flow 2nd stage
// @Param body body protocol.CredentialAssertionResponse true "authenticator assertion Response"
// @Success 200 {object} Response "The Response object"
// @Success 200 {object} controllers.Response "The Response object"
// @router /webauthn/signin/finish [post]
func (c *ApiController) WebAuthnSigninFinish() {
responseType := c.Input().Get("responseType")

2
go.mod
View File

@@ -49,7 +49,7 @@ require (
github.com/robfig/cron/v3 v3.0.1
github.com/russellhaering/gosaml2 v0.9.0
github.com/russellhaering/goxmldsig v1.2.0
github.com/sashabaranov/go-openai v1.9.1
github.com/sashabaranov/go-openai v1.12.0
github.com/satori/go.uuid v1.2.0
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible

2
go.sum
View File

@@ -548,6 +548,8 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sashabaranov/go-openai v1.9.1 h1:3N52HkJKo9Zlo/oe1AVv5ZkCOny0ra58/ACvAxkN3MM=
github.com/sashabaranov/go-openai v1.9.1/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
github.com/sashabaranov/go-openai v1.12.0 h1:aRNHH0gtVfrpIaEolD0sWrLLRnYQNK4cH/bIAHwL8Rk=
github.com/sashabaranov/go-openai v1.12.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "Die Anmeldeart \"Anmeldung mit Passwort\" ist für die Anwendung nicht aktiviert",
"The provider: %s is not enabled for the application": "Der Anbieter: %s ist nicht für die Anwendung aktiviert",
"Unauthorized operation": "Nicht autorisierte Operation",
"Unknown authentication type (not password or provider), form = %s": "Unbekannter Authentifizierungstyp (nicht Passwort oder Anbieter), Formular = %s"
"Unknown authentication type (not password or provider), form = %s": "Unbekannter Authentifizierungstyp (nicht Passwort oder Anbieter), Formular = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "Service %s und %s stimmen nicht überein"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application",
"The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application",
"Unauthorized operation": "Unauthorized operation",
"Unknown authentication type (not password or provider), form = %s": "Unknown authentication type (not password or provider), form = %s"
"Unknown authentication type (not password or provider), form = %s": "Unknown authentication type (not password or provider), form = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "Service %s and %s do not match"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "El método de inicio de sesión: inicio de sesión con contraseña no está habilitado para la aplicación",
"The provider: %s is not enabled for the application": "El proveedor: %s no está habilitado para la aplicación",
"Unauthorized operation": "Operación no autorizada",
"Unknown authentication type (not password or provider), form = %s": "Tipo de autenticación desconocido (no es contraseña o proveedor), formulario = %s"
"Unknown authentication type (not password or provider), form = %s": "Tipo de autenticación desconocido (no es contraseña o proveedor), formulario = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "Los servicios %s y %s no coinciden"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "La méthode de connexion : connexion avec mot de passe n'est pas activée pour l'application",
"The provider: %s is not enabled for the application": "Le fournisseur :%s n'est pas activé pour l'application",
"Unauthorized operation": "Opération non autorisée",
"Unknown authentication type (not password or provider), form = %s": "Type d'authentification inconnu (pas de mot de passe ou de fournisseur), formulaire = %s"
"Unknown authentication type (not password or provider), form = %s": "Type d'authentification inconnu (pas de mot de passe ou de fournisseur), formulaire = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "Les services %s et %s ne correspondent pas"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "Metode login: login dengan kata sandi tidak diaktifkan untuk aplikasi tersebut",
"The provider: %s is not enabled for the application": "Penyedia: %s tidak diaktifkan untuk aplikasi ini",
"Unauthorized operation": "Operasi tidak sah",
"Unknown authentication type (not password or provider), form = %s": "Jenis otentikasi tidak diketahui (bukan kata sandi atau pemberi), formulir = %s"
"Unknown authentication type (not password or provider), form = %s": "Jenis otentikasi tidak diketahui (bukan kata sandi atau pemberi), formulir = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "Layanan %s dan %s tidak cocok"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "ログイン方法:パスワードでのログインはアプリケーションで有効になっていません",
"The provider: %s is not enabled for the application": "プロバイダー:%sはアプリケーションでは有効化されていません",
"Unauthorized operation": "不正操作",
"Unknown authentication type (not password or provider), form = %s": "不明な認証タイプ(パスワードまたはプロバイダーではない)フォーム=%s"
"Unknown authentication type (not password or provider), form = %s": "不明な認証タイプ(パスワードまたはプロバイダーではない)フォーム=%s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "サービス%sと%sは一致しません"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "어플리케이션에서는 암호를 사용한 로그인 방법이 활성화되어 있지 않습니다",
"The provider: %s is not enabled for the application": "제공자 %s은(는) 응용 프로그램에서 활성화되어 있지 않습니다",
"Unauthorized operation": "무단 조작",
"Unknown authentication type (not password or provider), form = %s": "알 수 없는 인증 유형(암호 또는 공급자가 아님), 폼 = %s"
"Unknown authentication type (not password or provider), form = %s": "알 수 없는 인증 유형(암호 또는 공급자가 아님), 폼 = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "서비스 %s와 %s는 일치하지 않습니다"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "The login method: login with password is not enabled for the application",
"The provider: %s is not enabled for the application": "The provider: %s is not enabled for the application",
"Unauthorized operation": "Unauthorized operation",
"Unknown authentication type (not password or provider), form = %s": "Unknown authentication type (not password or provider), form = %s"
"Unknown authentication type (not password or provider), form = %s": "Unknown authentication type (not password or provider), form = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "Service %s and %s do not match"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "Метод входа: вход с паролем не включен для приложения",
"The provider: %s is not enabled for the application": "Провайдер: %s не включен для приложения",
"Unauthorized operation": "Несанкционированная операция",
"Unknown authentication type (not password or provider), form = %s": "Неизвестный тип аутентификации (не пароль и не провайдер), форма = %s"
"Unknown authentication type (not password or provider), form = %s": "Неизвестный тип аутентификации (не пароль и не провайдер), форма = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "Сервисы %s и %s не совпадают"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "Phương thức đăng nhập: đăng nhập bằng mật khẩu không được kích hoạt cho ứng dụng",
"The provider: %s is not enabled for the application": "Nhà cung cấp: %s không được kích hoạt cho ứng dụng",
"Unauthorized operation": "Hoạt động không được ủy quyền",
"Unknown authentication type (not password or provider), form = %s": "Loại xác thực không xác định (không phải mật khẩu hoặc nhà cung cấp), biểu mẫu = %s"
"Unknown authentication type (not password or provider), form = %s": "Loại xác thực không xác định (không phải mật khẩu hoặc nhà cung cấp), biểu mẫu = %s",
"User's tag: %s is not listed in the application's tags": "User's tag: %s is not listed in the application's tags"
},
"cas": {
"Service %s and %s do not match": "Dịch sang tiếng Việt: Dịch vụ %s và %s không khớp"

View File

@@ -18,7 +18,8 @@
"The login method: login with password is not enabled for the application": "该应用禁止采用密码登录方式",
"The provider: %s is not enabled for the application": "该应用的提供商: %s未被启用",
"Unauthorized operation": "未授权的操作",
"Unknown authentication type (not password or provider), form = %s": "未知的认证类型(非密码或第三方提供商):%s"
"Unknown authentication type (not password or provider), form = %s": "未知的认证类型(非密码或第三方提供商):%s",
"User's tag: %s is not listed in the application's tags": "用户的标签: %s不在该应用的标签列表中"
},
"cas": {
"Service %s and %s do not match": "服务%s与%s不匹配"

View File

@@ -57,6 +57,7 @@ type Application struct {
SignupItems []*SignupItem `xorm:"varchar(1000)" json:"signupItems"`
GrantTypes []string `xorm:"varchar(1000)" json:"grantTypes"`
OrganizationObj *Organization `xorm:"-" json:"organizationObj"`
Tags []string `xorm:"mediumtext" json:"tags"`
ClientId string `xorm:"varchar(100)" json:"clientId"`
ClientSecret string `xorm:"varchar(100)" json:"clientSecret"`

View File

@@ -184,6 +184,7 @@ func initBuiltInApplication() {
{Name: "Phone", Visible: true, Required: true, Prompted: false, Rule: "None"},
{Name: "Agreement", Visible: true, Required: true, Prompted: false, Rule: "None"},
},
Tags: []string{},
RedirectUris: []string{},
ExpireInHours: 168,
FormOffset: 2,

View File

@@ -145,6 +145,9 @@ func readInitDataFromFile(filePath string) (*InitData, error) {
if application.RedirectUris == nil {
application.RedirectUris = []string{}
}
if application.Tags == nil {
application.Tags = []string{}
}
}
for _, permission := range data.Permissions {
if permission.Actions == nil {

View File

@@ -104,10 +104,15 @@ func GetOrganizationsByFields(owner string, fields ...string) ([]*Organization,
return organizations, nil
}
func GetPaginationOrganizations(owner string, offset, limit int, field, value, sortField, sortOrder string) ([]*Organization, error) {
func GetPaginationOrganizations(owner string, name string, offset, limit int, field, value, sortField, sortOrder string) ([]*Organization, error) {
organizations := []*Organization{}
session := GetSession(owner, offset, limit, field, value, sortField, sortOrder)
err := session.Find(&organizations)
var err error
if name != "" {
err = session.Find(&organizations, &Organization{Name: name})
} else {
err = session.Find(&organizations)
}
if err != nil {
return nil, err
}

View File

@@ -43,6 +43,34 @@
}
}
},
"/api/add-adapter": {
"post": {
"tags": [
"Adapter API"
],
"description": "add adapter",
"operationId": "ApiController.AddCasbinAdapter",
"parameters": [
{
"in": "body",
"name": "body",
"description": "The details of the adapter",
"required": true,
"schema": {
"$ref": "#/definitions/object.Adapter"
}
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/controllers.Response"
}
}
}
}
},
"/api/add-application": {
"post": {
"tags": [
@@ -127,6 +155,34 @@
}
}
},
"/api/add-group": {
"post": {
"tags": [
"Group API"
],
"description": "add group",
"operationId": "ApiController.AddGroup",
"parameters": [
{
"in": "body",
"name": "body",
"description": "The details of the group",
"required": true,
"schema": {
"$ref": "#/definitions/object.Group"
}
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/controllers.Response"
}
}
}
}
},
"/api/add-ldap": {
"post": {
"tags": [
@@ -599,6 +655,14 @@
}
}
},
"/api/add-user-keys": {
"post": {
"tags": [
"User API"
],
"operationId": "ApiController.AddUserkeys"
}
},
"/api/add-webhook": {
"post": {
"tags": [
@@ -782,13 +846,13 @@
"tags": [
"Enforce API"
],
"description": "perform enforce",
"description": "Call Casbin BatchEnforce API",
"operationId": "ApiController.BatchEnforce",
"parameters": [
{
"in": "body",
"name": "body",
"description": "casbin request array",
"description": "array of casbin requests",
"required": true,
"schema": {
"$ref": "#/definitions/object.CasbinRequest"
@@ -858,6 +922,34 @@
"operationId": "ApiController.CheckUserPassword"
}
},
"/api/delete-adapter": {
"post": {
"tags": [
"Adapter API"
],
"description": "delete adapter",
"operationId": "ApiController.DeleteCasbinAdapter",
"parameters": [
{
"in": "body",
"name": "body",
"description": "The details of the adapter",
"required": true,
"schema": {
"$ref": "#/definitions/object.Adapter"
}
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/controllers.Response"
}
}
}
}
},
"/api/delete-application": {
"post": {
"tags": [
@@ -942,6 +1034,34 @@
}
}
},
"/api/delete-group": {
"post": {
"tags": [
"Group API"
],
"description": "delete group",
"operationId": "ApiController.DeleteGroup",
"parameters": [
{
"in": "body",
"name": "body",
"description": "The details of the group",
"required": true,
"schema": {
"$ref": "#/definitions/object.Group"
}
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/controllers.Response"
}
}
}
}
},
"/api/delete-ldap": {
"post": {
"tags": [
@@ -1429,13 +1549,13 @@
"tags": [
"Enforce API"
],
"description": "perform enforce",
"description": "Call Casbin Enforce API",
"operationId": "ApiController.Enforce",
"parameters": [
{
"in": "body",
"name": "body",
"description": "casbin request",
"description": "Casbin request",
"required": true,
"schema": {
"$ref": "#/definitions/object.CasbinRequest"
@@ -1487,6 +1607,61 @@
}
}
},
"/api/get-adapter": {
"get": {
"tags": [
"Adapter API"
],
"description": "get adapter",
"operationId": "ApiController.GetCasbinAdapter",
"parameters": [
{
"in": "query",
"name": "id",
"description": "The id ( owner/name ) of the adapter",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/object.Adapter"
}
}
}
}
},
"/api/get-adapters": {
"get": {
"tags": [
"Adapter API"
],
"description": "get adapters",
"operationId": "ApiController.GetCasbinAdapters",
"parameters": [
{
"in": "query",
"name": "owner",
"description": "The owner of adapters",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/object.Adapter"
}
}
}
}
}
},
"/api/get-app-login": {
"get": {
"tags": [
@@ -1825,6 +2000,61 @@
}
}
},
"/api/get-group": {
"get": {
"tags": [
"Group API"
],
"description": "get group",
"operationId": "ApiController.GetGroup",
"parameters": [
{
"in": "query",
"name": "id",
"description": "The id ( owner/name ) of the group",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/object.Group"
}
}
}
}
},
"/api/get-groups": {
"get": {
"tags": [
"Group API"
],
"description": "get groups",
"operationId": "ApiController.GetGroups",
"parameters": [
{
"in": "query",
"name": "owner",
"description": "The owner of groups",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/object.Group"
}
}
}
}
}
},
"/api/get-ldap": {
"get": {
"tags": [
@@ -2045,7 +2275,7 @@
"tags": [
"Organization API"
],
"description": "get all organization names",
"description": "get all organization name and displayName",
"operationId": "ApiController.GetOrganizationNames",
"parameters": [
{
@@ -2338,7 +2568,7 @@
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/object.pricing"
"$ref": "#/definitions/object.Pricing"
}
}
}
@@ -2753,7 +2983,7 @@
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/object.subscription"
"$ref": "#/definitions/object.Subscription"
}
}
}
@@ -3328,7 +3558,7 @@
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/Response"
"$ref": "#/definitions/controllers.Response"
}
}
}
@@ -3598,9 +3828,9 @@
"operationId": "ApiController.MfaSetupInitiate",
"responses": {
"200": {
"description": "Response object",
"description": "The Response object",
"schema": {
"$ref": "#/definitions/The"
"$ref": "#/definitions/controllers.Response"
}
}
}
@@ -3799,6 +4029,41 @@
]
}
},
"/api/update-adapter": {
"post": {
"tags": [
"Adapter API"
],
"description": "update adapter",
"operationId": "ApiController.UpdateCasbinAdapter",
"parameters": [
{
"in": "query",
"name": "id",
"description": "The id ( owner/name ) of the adapter",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "The details of the adapter",
"required": true,
"schema": {
"$ref": "#/definitions/object.Adapter"
}
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/controllers.Response"
}
}
}
}
},
"/api/update-application": {
"post": {
"tags": [
@@ -3904,6 +4169,41 @@
}
}
},
"/api/update-group": {
"post": {
"tags": [
"Group API"
],
"description": "update group",
"operationId": "ApiController.UpdateGroup",
"parameters": [
{
"in": "query",
"name": "id",
"description": "The id ( owner/name ) of the group",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "The details of the group",
"required": true,
"schema": {
"$ref": "#/definitions/object.Group"
}
}
],
"responses": {
"200": {
"description": "The Response object",
"schema": {
"$ref": "#/definitions/controllers.Response"
}
}
}
}
},
"/api/update-ldap": {
"post": {
"tags": [
@@ -4579,7 +4879,7 @@
"200": {
"description": "\"The Response object\"",
"schema": {
"$ref": "#/definitions/Response"
"$ref": "#/definitions/controllers.Response"
}
}
}
@@ -4624,7 +4924,7 @@
"200": {
"description": "\"The Response object\"",
"schema": {
"$ref": "#/definitions/Response"
"$ref": "#/definitions/controllers.Response"
}
}
}
@@ -4632,14 +4932,6 @@
}
},
"definitions": {
"1225.0xc0002e2ae0.false": {
"title": "false",
"type": "object"
},
"1260.0xc0002e2b10.false": {
"title": "false",
"type": "object"
},
"LaravelResponse": {
"title": "LaravelResponse",
"type": "object"
@@ -4648,10 +4940,6 @@
"title": "Response",
"type": "object"
},
"The": {
"title": "The",
"type": "object"
},
"controllers.AuthForm": {
"title": "AuthForm",
"type": "object"
@@ -4685,10 +4973,16 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/1225.0xc0002e2ae0.false"
"additionalProperties": {
"description": "support string | class | List\u003cclass\u003e and os on",
"type": "string"
}
},
"data2": {
"$ref": "#/definitions/1260.0xc0002e2b10.false"
"additionalProperties": {
"description": "support string | class | List\u003cclass\u003e and os on",
"type": "string"
}
},
"msg": {
"type": "string"
@@ -4726,8 +5020,8 @@
"title": "JSONWebKey",
"type": "object"
},
"object.\u0026{179844 0xc000a02f90 false}": {
"title": "\u0026{179844 0xc000a02f90 false}",
"object": {
"title": "object",
"type": "object"
},
"object.AccountItem": {
@@ -4917,7 +5211,7 @@
"title": "CasbinRequest",
"type": "array",
"items": {
"$ref": "#/definitions/object.\u0026{179844 0xc000a02f90 false}"
"$ref": "#/definitions/object.CasbinRequest"
}
},
"object.Cert": {
@@ -5029,6 +5323,63 @@
}
}
},
"object.Group": {
"title": "Group",
"type": "object",
"properties": {
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/object.Group"
}
},
"contactEmail": {
"type": "string"
},
"createdTime": {
"type": "string"
},
"displayName": {
"type": "string"
},
"isEnabled": {
"type": "boolean"
},
"isTopGroup": {
"type": "boolean"
},
"key": {
"type": "string"
},
"manager": {
"type": "string"
},
"name": {
"type": "string"
},
"owner": {
"type": "string"
},
"parentId": {
"type": "string"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
"updatedTime": {
"type": "string"
},
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/object.User"
}
}
}
},
"object.Header": {
"title": "Header",
"type": "object",
@@ -5175,12 +5526,15 @@
"countryCode": {
"type": "string"
},
"id": {
"type": "string"
"enabled": {
"type": "boolean"
},
"isPreferred": {
"type": "boolean"
},
"mfaType": {
"type": "string"
},
"recoveryCodes": {
"type": "array",
"items": {
@@ -5190,9 +5544,6 @@
"secret": {
"type": "string"
},
"type": {
"type": "string"
},
"url": {
"type": "string"
}
@@ -5205,6 +5556,9 @@
"createdTime": {
"type": "string"
},
"description": {
"type": "string"
},
"displayName": {
"type": "string"
},
@@ -5362,6 +5716,12 @@
"owner": {
"type": "string"
},
"passwordOptions": {
"type": "array",
"items": {
"type": "string"
}
},
"passwordSalt": {
"type": "string"
},
@@ -5492,6 +5852,9 @@
"createdTime": {
"type": "string"
},
"description": {
"type": "string"
},
"displayName": {
"type": "string"
},
@@ -5611,9 +5974,6 @@
"displayName": {
"type": "string"
},
"hasTrial": {
"type": "boolean"
},
"isEnabled": {
"type": "boolean"
},
@@ -5933,6 +6293,9 @@
"createdTime": {
"type": "string"
},
"description": {
"type": "string"
},
"displayName": {
"type": "string"
},
@@ -6068,6 +6431,9 @@
"isEnabled": {
"type": "boolean"
},
"isReadOnly": {
"type": "boolean"
},
"name": {
"type": "string"
},
@@ -6248,6 +6614,12 @@
"title": "User",
"type": "object",
"properties": {
"accessKey": {
"type": "string"
},
"accessSecret": {
"type": "string"
},
"address": {
"type": "array",
"items": {
@@ -6275,6 +6647,9 @@
"avatar": {
"type": "string"
},
"avatarType": {
"type": "string"
},
"azuread": {
"type": "string"
},
@@ -6380,6 +6755,12 @@
"google": {
"type": "string"
},
"groups": {
"type": "array",
"items": {
"type": "string"
}
},
"hash": {
"type": "string"
},
@@ -6480,6 +6861,12 @@
"meetup": {
"type": "string"
},
"mfaEmailEnabled": {
"type": "boolean"
},
"mfaPhoneEnabled": {
"type": "boolean"
},
"microsoftonline": {
"type": "string"
},
@@ -6540,6 +6927,9 @@
"preHash": {
"type": "string"
},
"preferredMfaType": {
"type": "string"
},
"properties": {
"additionalProperties": {
"type": "string"
@@ -6552,6 +6942,12 @@
"type": "integer",
"format": "int64"
},
"recoveryCodes": {
"type": "array",
"items": {
"type": "string"
}
},
"region": {
"type": "string"
},
@@ -6605,6 +7001,9 @@
"title": {
"type": "string"
},
"totpSecret": {
"type": "string"
},
"tumblr": {
"type": "string"
},
@@ -6677,15 +7076,18 @@
"email": {
"type": "string"
},
"groups": {
"type": "array",
"items": {
"type": "string"
}
},
"iss": {
"type": "string"
},
"name": {
"type": "string"
},
"organization": {
"type": "string"
},
"phone": {
"type": "string"
},
@@ -6745,14 +7147,6 @@
}
}
},
"object.pricing": {
"title": "pricing",
"type": "object"
},
"object.subscription": {
"title": "subscription",
"type": "object"
},
"protocol.CredentialAssertion": {
"title": "CredentialAssertion",
"type": "object"

View File

@@ -28,6 +28,24 @@ paths:
description: ""
schema:
$ref: '#/definitions/object.OidcDiscovery'
/api/add-adapter:
post:
tags:
- Adapter API
description: add adapter
operationId: ApiController.AddCasbinAdapter
parameters:
- in: body
name: body
description: The details of the adapter
required: true
schema:
$ref: '#/definitions/object.Adapter'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/add-application:
post:
tags:
@@ -82,6 +100,24 @@ paths:
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/add-group:
post:
tags:
- Group API
description: add group
operationId: ApiController.AddGroup
parameters:
- in: body
name: body
description: The details of the group
required: true
schema:
$ref: '#/definitions/object.Group'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/add-ldap:
post:
tags:
@@ -386,6 +422,11 @@ paths:
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/add-user-keys:
post:
tags:
- User API
operationId: ApiController.AddUserkeys
/api/add-webhook:
post:
tags:
@@ -506,12 +547,12 @@ paths:
post:
tags:
- Enforce API
description: perform enforce
description: Call Casbin BatchEnforce API
operationId: ApiController.BatchEnforce
parameters:
- in: body
name: body
description: casbin request array
description: array of casbin requests
required: true
schema:
$ref: '#/definitions/object.CasbinRequest'
@@ -555,6 +596,24 @@ paths:
tags:
- User API
operationId: ApiController.CheckUserPassword
/api/delete-adapter:
post:
tags:
- Adapter API
description: delete adapter
operationId: ApiController.DeleteCasbinAdapter
parameters:
- in: body
name: body
description: The details of the adapter
required: true
schema:
$ref: '#/definitions/object.Adapter'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/delete-application:
post:
tags:
@@ -609,6 +668,24 @@ paths:
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/delete-group:
post:
tags:
- Group API
description: delete group
operationId: ApiController.DeleteGroup
parameters:
- in: body
name: body
description: The details of the group
required: true
schema:
$ref: '#/definitions/object.Group'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/delete-ldap:
post:
tags:
@@ -923,12 +1000,12 @@ paths:
post:
tags:
- Enforce API
description: perform enforce
description: Call Casbin Enforce API
operationId: ApiController.Enforce
parameters:
- in: body
name: body
description: casbin request
description: Casbin request
required: true
schema:
$ref: '#/definitions/object.CasbinRequest'
@@ -960,6 +1037,42 @@ paths:
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/get-adapter:
get:
tags:
- Adapter API
description: get adapter
operationId: ApiController.GetCasbinAdapter
parameters:
- in: query
name: id
description: The id ( owner/name ) of the adapter
required: true
type: string
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Adapter'
/api/get-adapters:
get:
tags:
- Adapter API
description: get adapters
operationId: ApiController.GetCasbinAdapters
parameters:
- in: query
name: owner
description: The owner of adapters
required: true
type: string
responses:
"200":
description: The Response object
schema:
type: array
items:
$ref: '#/definitions/object.Adapter'
/api/get-app-login:
get:
tags:
@@ -1183,6 +1296,42 @@ paths:
type: array
items:
$ref: '#/definitions/object.Cert'
/api/get-group:
get:
tags:
- Group API
description: get group
operationId: ApiController.GetGroup
parameters:
- in: query
name: id
description: The id ( owner/name ) of the group
required: true
type: string
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Group'
/api/get-groups:
get:
tags:
- Group API
description: get groups
operationId: ApiController.GetGroups
parameters:
- in: query
name: owner
description: The owner of groups
required: true
type: string
responses:
"200":
description: The Response object
schema:
type: array
items:
$ref: '#/definitions/object.Group'
/api/get-ldap:
get:
tags:
@@ -1327,7 +1476,7 @@ paths:
get:
tags:
- Organization API
description: get all organization names
description: get all organization name and displayName
operationId: ApiController.GetOrganizationNames
parameters:
- in: query
@@ -1521,7 +1670,7 @@ paths:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.pricing'
$ref: '#/definitions/object.Pricing'
/api/get-pricings:
get:
tags:
@@ -1793,7 +1942,7 @@ paths:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.subscription'
$ref: '#/definitions/object.Subscription'
/api/get-subscriptions:
get:
tags:
@@ -2172,7 +2321,7 @@ paths:
"200":
description: The Response object
schema:
$ref: '#/definitions/Response'
$ref: '#/definitions/controllers.Response'
/api/login/oauth/access_token:
post:
tags:
@@ -2351,9 +2500,9 @@ paths:
operationId: ApiController.MfaSetupInitiate
responses:
"200":
description: Response object
description: The Response object
schema:
$ref: '#/definitions/The'
$ref: '#/definitions/controllers.Response'
/api/mfa/setup/verify:
post:
tags:
@@ -2480,6 +2629,29 @@ paths:
post:
tags:
- Login API
/api/update-adapter:
post:
tags:
- Adapter API
description: update adapter
operationId: ApiController.UpdateCasbinAdapter
parameters:
- in: query
name: id
description: The id ( owner/name ) of the adapter
required: true
type: string
- in: body
name: body
description: The details of the adapter
required: true
schema:
$ref: '#/definitions/object.Adapter'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/update-application:
post:
tags:
@@ -2549,6 +2721,29 @@ paths:
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/update-group:
post:
tags:
- Group API
description: update group
operationId: ApiController.UpdateGroup
parameters:
- in: query
name: id
description: The id ( owner/name ) of the group
required: true
type: string
- in: body
name: body
description: The details of the group
required: true
schema:
$ref: '#/definitions/object.Group'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/update-ldap:
post:
tags:
@@ -2994,7 +3189,7 @@ paths:
"200":
description: '"The Response object"'
schema:
$ref: '#/definitions/Response'
$ref: '#/definitions/controllers.Response'
/api/webauthn/signup/begin:
get:
tags:
@@ -3023,23 +3218,14 @@ paths:
"200":
description: '"The Response object"'
schema:
$ref: '#/definitions/Response'
$ref: '#/definitions/controllers.Response'
definitions:
1225.0xc0002e2ae0.false:
title: "false"
type: object
1260.0xc0002e2b10.false:
title: "false"
type: object
LaravelResponse:
title: LaravelResponse
type: object
Response:
title: Response
type: object
The:
title: The
type: object
controllers.AuthForm:
title: AuthForm
type: object
@@ -3064,9 +3250,13 @@ definitions:
type: object
properties:
data:
$ref: '#/definitions/1225.0xc0002e2ae0.false'
additionalProperties:
description: support string | class | List<class> and os on
type: string
data2:
$ref: '#/definitions/1260.0xc0002e2b10.false'
additionalProperties:
description: support string | class | List<class> and os on
type: string
msg:
type: string
name:
@@ -3090,8 +3280,8 @@ definitions:
jose.JSONWebKey:
title: JSONWebKey
type: object
object.&{179844 0xc000a02f90 false}:
title: '&{179844 0xc000a02f90 false}'
object:
title: object
type: object
object.AccountItem:
title: AccountItem
@@ -3220,7 +3410,7 @@ definitions:
title: CasbinRequest
type: array
items:
$ref: '#/definitions/object.&{179844 0xc000a02f90 false}'
$ref: '#/definitions/object.CasbinRequest'
object.Cert:
title: Cert
type: object
@@ -3295,6 +3485,44 @@ definitions:
throughput:
type: number
format: double
object.Group:
title: Group
type: object
properties:
children:
type: array
items:
$ref: '#/definitions/object.Group'
contactEmail:
type: string
createdTime:
type: string
displayName:
type: string
isEnabled:
type: boolean
isTopGroup:
type: boolean
key:
type: string
manager:
type: string
name:
type: string
owner:
type: string
parentId:
type: string
title:
type: string
type:
type: string
updatedTime:
type: string
users:
type: array
items:
$ref: '#/definitions/object.User'
object.Header:
title: Header
type: object
@@ -3395,18 +3623,18 @@ definitions:
properties:
countryCode:
type: string
id:
type: string
enabled:
type: boolean
isPreferred:
type: boolean
mfaType:
type: string
recoveryCodes:
type: array
items:
type: string
secret:
type: string
type:
type: string
url:
type: string
object.Model:
@@ -3415,6 +3643,8 @@ definitions:
properties:
createdTime:
type: string
description:
type: string
displayName:
type: string
isEnabled:
@@ -3520,6 +3750,10 @@ definitions:
type: string
owner:
type: string
passwordOptions:
type: array
items:
type: string
passwordSalt:
type: string
passwordType:
@@ -3607,6 +3841,8 @@ definitions:
type: string
createdTime:
type: string
description:
type: string
displayName:
type: string
domains:
@@ -3687,8 +3923,6 @@ definitions:
type: string
displayName:
type: string
hasTrial:
type: boolean
isEnabled:
type: boolean
name:
@@ -3904,6 +4138,8 @@ definitions:
properties:
createdTime:
type: string
description:
type: string
displayName:
type: string
domains:
@@ -3995,6 +4231,8 @@ definitions:
type: string
isEnabled:
type: boolean
isReadOnly:
type: boolean
name:
type: string
organization:
@@ -4117,6 +4355,10 @@ definitions:
title: User
type: object
properties:
accessKey:
type: string
accessSecret:
type: string
address:
type: array
items:
@@ -4135,6 +4377,8 @@ definitions:
type: string
avatar:
type: string
avatarType:
type: string
azuread:
type: string
baidu:
@@ -4205,6 +4449,10 @@ definitions:
type: string
google:
type: string
groups:
type: array
items:
type: string
hash:
type: string
heroku:
@@ -4272,6 +4520,10 @@ definitions:
$ref: '#/definitions/object.ManagedAccount'
meetup:
type: string
mfaEmailEnabled:
type: boolean
mfaPhoneEnabled:
type: boolean
microsoftonline:
type: string
multiFactorAuths:
@@ -4312,6 +4564,8 @@ definitions:
type: string
preHash:
type: string
preferredMfaType:
type: string
properties:
additionalProperties:
type: string
@@ -4320,6 +4574,10 @@ definitions:
ranking:
type: integer
format: int64
recoveryCodes:
type: array
items:
type: string
region:
type: string
roles:
@@ -4356,6 +4614,8 @@ definitions:
type: string
title:
type: string
totpSecret:
type: string
tumblr:
type: string
twitch:
@@ -4404,12 +4664,14 @@ definitions:
type: string
email:
type: string
groups:
type: array
items:
type: string
iss:
type: string
name:
type: string
organization:
type: string
phone:
type: string
picture:
@@ -4448,12 +4710,6 @@ definitions:
type: string
url:
type: string
object.pricing:
title: pricing
type: object
object.subscription:
title: subscription
type: object
protocol.CredentialAssertion:
title: CredentialAssertion
type: object

View File

@@ -43,6 +43,15 @@ func ContainsString(values []string, val string) bool {
return sort.SearchStrings(values, val) != len(values)
}
func InSlice(slice []string, elem string) bool {
for _, val := range slice {
if val == elem {
return true
}
}
return false
}
func ReturnAnyNotEmpty(strs ...string) string {
for _, str := range strs {
if str != "" {

View File

@@ -25,8 +25,9 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class AdapterListPage extends BaseListPage {
newAdapter() {
const randomName = Setting.getRandomName();
const owner = Setting.getRequestOrganization(this.props.account);
return {
owner: this.props.account.owner,
owner: owner,
name: `adapter_${randomName}`,
createdTime: moment().format(),
type: "Database",
@@ -87,7 +88,7 @@ class AdapterListPage extends BaseListPage {
...this.getColumnSearchProps("name"),
render: (text, record, index) => {
return (
<Link to={`/adapters/${record.organization}/${text}`}>
<Link to={`/adapters/${record.owner}/${text}`}>
{text}
</Link>
);
@@ -246,7 +247,7 @@ class AdapterListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
AdapterBackend.getAdapters(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
AdapterBackend.getAdapters(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -86,6 +86,7 @@ import {withTranslation} from "react-i18next";
import ThemeSelect from "./common/select/ThemeSelect";
import SessionListPage from "./SessionListPage";
import MfaSetupPage from "./auth/MfaSetupPage";
import OrganizationSelect from "./common/select/OrganizationSelect";
const {Header, Footer, Content} = Layout;
@@ -106,7 +107,7 @@ class App extends Component {
Setting.initServerUrl();
Auth.initAuthWithConfig({
serverUrl: Setting.ServerUrl,
appName: "app-built-in", // the application name of Casdoor itself, do not change it
appName: Conf.DefaultApplication, // the application used in Casdoor root path: "/"
});
}
@@ -398,6 +399,17 @@ class App extends Component {
});
}} />
<LanguageSelect languages={this.state.account.organization.languages} />
{Setting.isAdminUser(this.state.account) && !Setting.isMobile() &&
<OrganizationSelect
initValue={Setting.getOrganization()}
withAll={true}
style={{marginRight: "20px", width: "180px", display: "flex"}}
onChange={(value) => {
Setting.setOrganization(value);
}}
className="select-box"
/>
}
</React.Fragment>
);
}
@@ -611,7 +623,7 @@ class App extends Component {
<Route exact path="/subscriptions" render={(props) => this.renderLoginIfNotLoggedIn(<SubscriptionListPage account={this.state.account} {...props} />)} />
<Route exact path="/subscriptions/:organizationName/:subscriptionName" render={(props) => this.renderLoginIfNotLoggedIn(<SubscriptionEditPage account={this.state.account} {...props} />)} />
<Route exact path="/products" render={(props) => this.renderLoginIfNotLoggedIn(<ProductListPage account={this.state.account} {...props} />)} />
<Route exact path="/products/:productName" render={(props) => this.renderLoginIfNotLoggedIn(<ProductEditPage account={this.state.account} {...props} />)} />
<Route exact path="/products/:organizationName/:productName" render={(props) => this.renderLoginIfNotLoggedIn(<ProductEditPage account={this.state.account} {...props} />)} />
<Route exact path="/products/:productName/buy" render={(props) => this.renderLoginIfNotLoggedIn(<ProductBuyPage account={this.state.account} {...props} />)} />
<Route exact path="/payments" render={(props) => this.renderLoginIfNotLoggedIn(<PaymentListPage account={this.state.account} {...props} />)} />
<Route exact path="/payments/:paymentName" render={(props) => this.renderLoginIfNotLoggedIn(<PaymentEditPage account={this.state.account} {...props} />)} />
@@ -651,6 +663,7 @@ class App extends Component {
this.props.history.push(key);
}
};
const menuStyleRight = Setting.isAdminUser(this.state.account) && !Setting.isMobile() ? "calc(180px + 260px)" : "260px";
return (
<Layout id="parent-area">
<Header style={{padding: "0", marginBottom: "3px", backgroundColor: this.state.themeAlgorithm.includes("dark") ? "black" : "white"}}>
@@ -680,7 +693,7 @@ class App extends Component {
items={this.getMenuItems()}
mode={"horizontal"}
selectedKeys={[this.state.selectedMenuKey]}
style={{position: "absolute", left: "145px", right: "260px"}}
style={{position: "absolute", left: "145px", right: menuStyleRight}}
/>
}
{

View File

@@ -132,6 +132,11 @@ class ApplicationEditPage extends React.Component {
if (res.grantTypes === null || res.grantTypes === undefined || res.grantTypes.length === 0) {
res.grantTypes = ["authorization_code"];
}
if (res.tags === null || res.tags === undefined) {
res.tags = [];
}
this.setState({
application: res,
});
@@ -312,6 +317,18 @@ class ApplicationEditPage extends React.Component {
</Select>
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("organization:Tags"), i18next.t("application:Tags - Tooltip"))} :
</Col>
<Col span={22} >
<Select virtual={false} mode="tags" style={{width: "100%"}} value={this.state.application.tags} onChange={(value => {this.updateApplicationField("tags", value);})}>
{
this.state.application.tags?.map((item, index) => <Option key={index} value={item}>{item}</Option>)
}
</Select>
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("provider:Client ID"), i18next.t("provider:Client ID - Tooltip"))} :

View File

@@ -28,18 +28,13 @@ class ApplicationListPage extends BaseListPage {
super(props);
}
componentDidMount() {
this.setState({
organizationName: this.props.account.owner,
});
}
newApplication() {
const randomName = Setting.getRandomName();
const organizationName = Setting.getRequestOrganization(this.props.account);
return {
owner: "admin", // this.props.account.applicationName,
name: `application_${randomName}`,
organization: this.state.organizationName,
organization: organizationName,
createdTime: moment().format(),
displayName: `New Application - ${randomName}`,
logo: `${Setting.StaticBaseUrl}/img/casdoor-logo_1185x256.png`,
@@ -273,8 +268,8 @@ class ApplicationListPage extends BaseListPage {
const field = params.searchedColumn, value = params.searchText;
const sortField = params.sortField, sortOrder = params.sortOrder;
this.setState({loading: true});
(Setting.isAdminUser(this.props.account) ? ApplicationBackend.getApplications("admin", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) :
ApplicationBackend.getApplicationsByOrganization("admin", this.props.account.organization.name, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder))
(Setting.isDefaultOrganizationSelected(this.props.account) ? ApplicationBackend.getApplications("admin", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) :
ApplicationBackend.getApplicationsByOrganization("admin", Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder))
.then((res) => {
this.setState({
loading: false,

View File

@@ -17,6 +17,7 @@ import {Button, Input, Result, Space} from "antd";
import {SearchOutlined} from "@ant-design/icons";
import Highlighter from "react-highlight-words";
import i18next from "i18next";
import * as Setting from "./Setting";
class BaseListPage extends React.Component {
constructor(props) {
@@ -35,6 +36,22 @@ class BaseListPage extends React.Component {
};
}
handleOrganizationChange = () => {
const {pagination} = this.state;
this.fetch({pagination});
};
componentDidMount() {
window.addEventListener("storageOrganizationChanged", this.handleOrganizationChange);
if (!Setting.isAdminUser(this.props.account)) {
Setting.setOrganization("All");
}
}
componentWillUnmount() {
window.removeEventListener("storageOrganizationChanged", this.handleOrganizationChange);
}
UNSAFE_componentWillMount() {
const {pagination} = this.state;
this.fetch({pagination});

View File

@@ -28,6 +28,7 @@ class CertListPage extends BaseListPage {
}
componentDidMount() {
super.componentDidMount();
this.setState({
owner: Setting.isAdminUser(this.props.account) ? "admin" : this.props.account.owner,
});
@@ -35,8 +36,9 @@ class CertListPage extends BaseListPage {
newCert() {
const randomName = Setting.getRandomName();
const owner = Setting.isDefaultOrganizationSelected(this.props.account) ? this.state.owner : Setting.getRequestOrganization(this.props.account);
return {
owner: this.state.owner,
owner: owner,
name: `cert_${randomName}`,
createdTime: moment().format(),
displayName: `New Cert - ${randomName}`,
@@ -236,8 +238,8 @@ class CertListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
(Setting.isAdminUser(this.props.account) ? CertBackend.getGlobleCerts(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
: CertBackend.getCerts(this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder))
(Setting.isDefaultOrganizationSelected(this.props.account) ? CertBackend.getGlobleCerts(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
: CertBackend.getCerts(Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder))
.then((res) => {
this.setState({
loading: false,

View File

@@ -25,12 +25,13 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class ChatListPage extends BaseListPage {
newChat() {
const randomName = Setting.getRandomName();
const organizationName = Setting.getRequestOrganization(this.props.account);
return {
owner: "admin", // this.props.account.applicationName,
name: `chat_${randomName}`,
createdTime: moment().format(),
updatedTime: moment().format(),
organization: this.props.account.owner,
organization: organizationName,
displayName: `New Chat - ${randomName}`,
type: "Single",
category: "Chat Category - 1",

View File

@@ -1,34 +1,34 @@
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export const ShowGithubCorner = false;
export const GithubRepo = "https://github.com/casdoor/casdoor";
export const IsDemoMode = false;
export const ForceLanguage = "";
export const DefaultLanguage = "en";
export const EnableExtraPages = true;
export const EnableChatPages = true;
export const InitThemeAlgorithm = true;
export const ThemeDefault = {
themeType: "default",
colorPrimary: "#5734d3",
borderRadius: 6,
isCompact: false,
};
export const CustomFooter = null;
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export const DefaultApplication = "app-built-in";
export const ShowGithubCorner = false;
export const IsDemoMode = false;
export const ForceLanguage = "";
export const DefaultLanguage = "en";
export const EnableExtraPages = true;
export const EnableChatPages = true;
export const InitThemeAlgorithm = true;
export const ThemeDefault = {
themeType: "default",
colorPrimary: "#5734d3",
borderRadius: 6,
isCompact: false,
};
export const CustomFooter = null;

View File

@@ -49,8 +49,9 @@ class GroupListPage extends BaseListPage {
newGroup() {
const randomName = Setting.getRandomName();
const owner = Setting.getRequestOrganization(this.props.account);
return {
owner: this.props.account.owner,
owner: owner,
name: `group_${randomName}`,
createdTime: moment().format(),
updatedTime: moment().format(),
@@ -251,7 +252,7 @@ class GroupListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
GroupBackend.getGroups(this.state.owner, false, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
GroupBackend.getGroups(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), false, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -25,11 +25,12 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class MessageListPage extends BaseListPage {
newMessage() {
const randomName = Setting.getRandomName();
const organizationName = Setting.getRequestOrganization(this.props.account);
return {
owner: "admin", // this.props.account.messagename,
name: `message_${randomName}`,
createdTime: moment().format(),
organization: this.props.account.owner,
organization: organizationName,
chat: "",
replyTo: "",
author: `${this.props.account.owner}/${this.props.account.name}`,
@@ -208,7 +209,7 @@ class MessageListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
MessageBackend.getMessages("admin", Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
MessageBackend.getMessages("admin", Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -40,8 +40,9 @@ m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act`;
class ModelListPage extends BaseListPage {
newModel() {
const randomName = Setting.getRandomName();
const owner = Setting.getRequestOrganization(this.props.account);
return {
owner: this.props.account.owner,
owner: owner,
name: `model_${randomName}`,
createdTime: moment().format(),
displayName: `New Model - ${randomName}`,
@@ -202,7 +203,7 @@ class ModelListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
ModelBackend.getModels(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
ModelBackend.getModels(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -427,6 +427,7 @@ class OrganizationEditPage extends React.Component {
this.setState({
organizationName: this.state.organization.name,
});
window.dispatchEvent(new Event("storageOrganizationsChanged"));
if (willExist) {
this.props.history.push("/organizations");
@@ -448,6 +449,7 @@ class OrganizationEditPage extends React.Component {
.then((res) => {
if (res.status === "ok") {
this.props.history.push("/organizations");
window.dispatchEvent(new Event("storageOrganizationsChanged"));
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
}

View File

@@ -83,6 +83,7 @@ class OrganizationListPage extends BaseListPage {
if (res.status === "ok") {
this.props.history.push({pathname: `/organizations/${newOrganization.name}`, mode: "add"});
Setting.showMessage("success", i18next.t("general:Successfully added"));
window.dispatchEvent(new Event("storageOrganizationsChanged"));
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to add")}: ${res.msg}`);
}
@@ -99,8 +100,11 @@ class OrganizationListPage extends BaseListPage {
Setting.showMessage("success", i18next.t("general:Successfully deleted"));
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
pagination: {
...this.state.pagination,
total: this.state.pagination.total - 1},
});
window.dispatchEvent(new Event("storageOrganizationsChanged"));
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to delete")}: ${res.msg}`);
}
@@ -275,7 +279,7 @@ class OrganizationListPage extends BaseListPage {
value = params.passwordType;
}
this.setState({loading: true});
OrganizationBackend.getOrganizations("admin", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
OrganizationBackend.getOrganizations("admin", Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -26,6 +26,7 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class PaymentListPage extends BaseListPage {
newPayment() {
const randomName = Setting.getRandomName();
const organizationName = Setting.getRequestOrganization(this.props.account);
return {
owner: "admin",
name: `payment_${randomName}`,
@@ -33,7 +34,7 @@ class PaymentListPage extends BaseListPage {
displayName: `New Payment - ${randomName}`,
provider: "provider_pay_paypal",
type: "PayPal",
organization: this.props.account.owner,
organization: organizationName,
user: "admin",
productName: "computer-1",
productDisplayName: "A notebook computer",
@@ -265,7 +266,7 @@ class PaymentListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
PaymentBackend.getPayments("admin", Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
PaymentBackend.getPayments("admin", Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -26,8 +26,9 @@ import {UploadOutlined} from "@ant-design/icons";
class PermissionListPage extends BaseListPage {
newPermission() {
const randomName = Setting.getRandomName();
const owner = Setting.getRequestOrganization(this.props.account);
return {
owner: this.props.account.owner,
owner: owner,
name: `permission_${randomName}`,
createdTime: moment().format(),
displayName: `New Permission - ${randomName}`,
@@ -383,7 +384,7 @@ class PermissionListPage extends BaseListPage {
this.setState({loading: true});
const getPermissions = Setting.isLocalAdminUser(this.props.account) ? PermissionBackend.getPermissions : PermissionBackend.getPermissionsBySubmitter;
getPermissions(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
getPermissions(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -25,8 +25,7 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class PlanListPage extends BaseListPage {
newPlan() {
const randomName = Setting.getRandomName();
const owner = (this.state.organizationName !== undefined) ? this.state.organizationName : this.props.account.owner;
const owner = Setting.getRequestOrganization(this.props.account);
return {
owner: owner,
name: `plan_${randomName}`,
@@ -219,7 +218,7 @@ class PlanListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
PlanBackend.getPlans(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
PlanBackend.getPlans(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -25,8 +25,7 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class PricingListPage extends BaseListPage {
newPricing() {
const randomName = Setting.getRandomName();
const owner = (this.state.organizationName !== undefined) ? this.state.organizationName : this.props.account.owner;
const owner = Setting.getRequestOrganization(this.props.account);
return {
owner: owner,
name: `pricing_${randomName}`,
@@ -188,7 +187,7 @@ class PricingListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
PricingBackend.getPricings(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
PricingBackend.getPricings(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -20,6 +20,7 @@ import i18next from "i18next";
import {LinkOutlined} from "@ant-design/icons";
import * as ProviderBackend from "./backend/ProviderBackend";
import ProductBuyPage from "./ProductBuyPage";
import * as OrganizationBackend from "./backend/OrganizationBackend";
const {Option} = Select;
@@ -39,11 +40,12 @@ class ProductEditPage extends React.Component {
UNSAFE_componentWillMount() {
this.getProduct();
this.getOrganizations();
this.getPaymentProviders();
}
getProduct() {
ProductBackend.getProduct(this.props.account.owner, this.state.productName)
ProductBackend.getProduct(this.state.organizationName, this.state.productName)
.then((product) => {
if (product === null) {
this.props.history.push("/404");
@@ -56,6 +58,15 @@ class ProductEditPage extends React.Component {
});
}
getOrganizations() {
OrganizationBackend.getOrganizations("admin")
.then((res) => {
this.setState({
organizations: (res.msg === undefined) ? res : [],
});
});
}
getPaymentProviders() {
ProviderBackend.getProviders(this.props.account.owner)
.then((res) => {
@@ -312,7 +323,7 @@ class ProductEditPage extends React.Component {
if (willExist) {
this.props.history.push("/products");
} else {
this.props.history.push(`/products/${this.state.product.name}`);
this.props.history.push(`/products/${this.state.product.owner}/${this.state.product.name}`);
}
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);

View File

@@ -26,8 +26,9 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class ProductListPage extends BaseListPage {
newProduct() {
const randomName = Setting.getRandomName();
const owner = Setting.getRequestOrganization(this.props.account);
return {
owner: this.props.account.owner,
owner: owner,
name: `product_${randomName}`,
createdTime: moment().format(),
displayName: `New Product - ${randomName}`,
@@ -47,7 +48,7 @@ class ProductListPage extends BaseListPage {
ProductBackend.addProduct(newProduct)
.then((res) => {
if (res.status === "ok") {
this.props.history.push({pathname: `/products/${newProduct.name}`, mode: "add"});
this.props.history.push({pathname: `/products/${newProduct.owner}/${newProduct.name}`, mode: "add"});
Setting.showMessage("success", i18next.t("general:Successfully added"));
} else {
Setting.showMessage("error", `${i18next.t("general:Failed to add")}: ${res.msg}`);
@@ -88,7 +89,7 @@ class ProductListPage extends BaseListPage {
...this.getColumnSearchProps("name"),
render: (text, record, index) => {
return (
<Link to={`/products/${text}`}>
<Link to={`/products/${record.owner}/${text}`}>
{text}
</Link>
);
@@ -201,7 +202,7 @@ class ProductListPage extends BaseListPage {
size="small"
locale={{emptyText: " "}}
dataSource={providers}
renderItem={(providerName, i) => {
renderItem={(providerName, record, i) => {
return (
<List.Item>
<div style={{display: "inline"}}>
@@ -247,7 +248,7 @@ class ProductListPage extends BaseListPage {
return (
<div>
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} onClick={() => this.props.history.push(`/products/${record.name}/buy`)}>{i18next.t("product:Buy")}</Button>
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/products/${record.name}`)}>{i18next.t("general:Edit")}</Button>
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/products/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
<PopconfirmModal
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
onConfirm={() => this.deleteProduct(index)}
@@ -268,7 +269,7 @@ class ProductListPage extends BaseListPage {
return (
<div>
<Table scroll={{x: "max-content"}} columns={columns} dataSource={products} rowKey="name" size="middle" bordered pagination={paginationProps}
<Table scroll={{x: "max-content"}} columns={columns} dataSource={products} rowKey={(record) => `${record.owner}/${record.name}`} size="middle" bordered pagination={paginationProps}
title={() => (
<div>
{i18next.t("general:Products")}&nbsp;&nbsp;&nbsp;&nbsp;
@@ -290,7 +291,7 @@ class ProductListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
ProductBackend.getProducts(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
ProductBackend.getProducts(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -29,6 +29,7 @@ class ProviderListPage extends BaseListPage {
}
componentDidMount() {
super.componentDidMount();
this.setState({
owner: Setting.isAdminUser(this.props.account) ? "admin" : this.props.account.owner,
});
@@ -36,8 +37,9 @@ class ProviderListPage extends BaseListPage {
newProvider() {
const randomName = Setting.getRandomName();
const owner = Setting.isDefaultOrganizationSelected(this.props.account) ? this.state.owner : Setting.getRequestOrganization();
return {
owner: this.state.owner,
owner: owner,
name: `provider_${randomName}`,
createdTime: moment().format(),
displayName: `New Provider - ${randomName}`,
@@ -256,8 +258,8 @@ class ProviderListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
(Setting.isAdminUser(this.props.account) ? ProviderBackend.getGlobalProviders(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
: ProviderBackend.getProviders(this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder))
(Setting.isDefaultOrganizationSelected(this.props.account) ? ProviderBackend.getGlobalProviders(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
: ProviderBackend.getProviders(Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder))
.then((res) => {
this.setState({
loading: false,

View File

@@ -209,7 +209,7 @@ class RecordListPage extends BaseListPage {
value = params.method;
}
this.setState({loading: true});
RecordBackend.getRecords(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
RecordBackend.getRecords(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -309,7 +309,7 @@ class ResourceListPage extends BaseListPage {
const field = params.searchedColumn, value = params.searchText;
const sortField = params.sortField, sortOrder = params.sortOrder;
this.setState({loading: true});
ResourceBackend.getResources(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, this.props.account.name, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
ResourceBackend.getResources(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), this.props.account.name, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -26,8 +26,9 @@ import {UploadOutlined} from "@ant-design/icons";
class RoleListPage extends BaseListPage {
newRole() {
const randomName = Setting.getRandomName();
const owner = Setting.getRequestOrganization(this.props.account);
return {
owner: this.props.account.owner,
owner: owner,
name: `role_${randomName}`,
createdTime: moment().format(),
displayName: `New Role - ${randomName}`,
@@ -258,7 +259,7 @@ class RoleListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
RoleBackend.getRoles(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
RoleBackend.getRoles(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -22,7 +22,6 @@ import * as SessionBackend from "./backend/SessionBackend";
import PopconfirmModal from "./common/modal/PopconfirmModal";
class SessionListPage extends BaseListPage {
deleteSession(i) {
SessionBackend.deleteSession(this.state.data[i])
.then((res) => {
@@ -134,7 +133,7 @@ class SessionListPage extends BaseListPage {
value = params.contentType;
}
this.setState({loading: true});
SessionBackend.getSessions(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
SessionBackend.getSessions(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -1164,3 +1164,27 @@ export function inIframe() {
return true;
}
}
export function getOrganization() {
const organization = localStorage.getItem("organization");
return organization !== null ? organization : "All";
}
export function setOrganization(organization) {
localStorage.setItem("organization", organization);
window.dispatchEvent(new Event("storageOrganizationChanged"));
}
export function getRequestOrganization(account) {
if (isAdminUser(account)) {
return getOrganization() === "All" ? account.owner : getOrganization();
}
return account.owner;
}
export function isDefaultOrganizationSelected(account) {
if (isAdminUser(account)) {
return getOrganization() === "All";
}
return false;
}

View File

@@ -25,7 +25,7 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class SubscriptionListPage extends BaseListPage {
newSubscription() {
const randomName = Setting.getRandomName();
const owner = (this.state.organizationName !== undefined) ? this.state.organizationName : this.props.account.owner;
const owner = Setting.getRequestOrganization(this.props.account);
const defaultDuration = 365;
return {
@@ -237,7 +237,7 @@ class SubscriptionListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
SubscriptionBackend.getSubscriptions(Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
SubscriptionBackend.getSubscriptions(Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -25,11 +25,12 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class SyncerListPage extends BaseListPage {
newSyncer() {
const randomName = Setting.getRandomName();
const organizationName = Setting.getRequestOrganization(this.props.account);
return {
owner: "admin",
name: `syncer_${randomName}`,
createdTime: moment().format(),
organization: this.props.account.owner,
organization: organizationName,
type: "Database",
host: "localhost",
port: 3306,
@@ -276,7 +277,7 @@ class SyncerListPage extends BaseListPage {
value = params.type;
}
this.setState({loading: true});
SyncerBackend.getSyncers("admin", Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
SyncerBackend.getSyncers("admin", Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -25,12 +25,13 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class TokenListPage extends BaseListPage {
newToken() {
const randomName = Setting.getRandomName();
const organizationName = Setting.getRequestOrganization(this.props.account);
return {
owner: "admin", // this.props.account.tokenname,
name: `token_${randomName}`,
createdTime: moment().format(),
application: "app-built-in",
organization: this.props.account.owner,
organization: organizationName,
user: "admin",
accessToken: "",
expiresIn: 7200,
@@ -240,7 +241,7 @@ class TokenListPage extends BaseListPage {
const field = params.searchedColumn, value = params.searchText;
const sortField = params.sortField, sortOrder = params.sortOrder;
this.setState({loading: true});
TokenBackend.getTokens("admin", Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
TokenBackend.getTokens("admin", Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -61,7 +61,7 @@ class UserListPage extends BaseListPage {
newUser() {
const randomName = Setting.getRandomName();
const owner = this.state.organizationName;
const owner = Setting.isDefaultOrganizationSelected(this.props.account) ? this.state.organizationName : Setting.getRequestOrganization(this.props.account);
return {
owner: owner,
name: `user_${randomName}`,
@@ -456,7 +456,7 @@ class UserListPage extends BaseListPage {
const sortField = params.sortField, sortOrder = params.sortOrder;
this.setState({loading: true});
if (this.props.match?.path === "/users") {
(Setting.isAdminUser(this.props.account) ? UserBackend.getGlobalUsers(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) : UserBackend.getUsers(this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder))
(Setting.isDefaultOrganizationSelected(this.props.account) ? UserBackend.getGlobalUsers(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) : UserBackend.getUsers(Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder))
.then((res) => {
this.setState({
loading: false,

View File

@@ -25,11 +25,12 @@ import PopconfirmModal from "./common/modal/PopconfirmModal";
class WebhookListPage extends BaseListPage {
newWebhook() {
const randomName = Setting.getRandomName();
const organizationName = Setting.getRequestOrganization(this.props.account);
return {
owner: "admin", // this.props.account.webhookname,
name: `webhook_${randomName}`,
createdTime: moment().format(),
organization: this.props.account.owner,
organization: organizationName,
url: "https://example.com/callback",
method: "POST",
contentType: "application/json",
@@ -240,7 +241,7 @@ class WebhookListPage extends BaseListPage {
value = params.contentType;
}
this.setState({loading: true});
WebhookBackend.getWebhooks("admin", Setting.isAdminUser(this.props.account) ? "" : this.props.account.owner, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
WebhookBackend.getWebhooks("admin", Setting.isDefaultOrganizationSelected(this.props.account) ? "" : Setting.getRequestOrganization(this.props.account), params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
this.setState({
loading: false,

View File

@@ -14,8 +14,8 @@
import * as Setting from "../Setting";
export function getOrganizations(owner, page = "", pageSize = "", field = "", value = "", sortField = "", sortOrder = "") {
return fetch(`${Setting.ServerUrl}/api/get-organizations?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
export function getOrganizations(owner, organizationName = "", page = "", pageSize = "", field = "", value = "", sortField = "", sortOrder = "") {
return fetch(`${Setting.ServerUrl}/api/get-organizations?owner=${owner}&organizationName=${organizationName}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {

View File

@@ -14,8 +14,8 @@
import * as Setting from "../Setting";
export function getRecords(page, pageSize, field = "", value = "", sortField = "", sortOrder = "") {
return fetch(`${Setting.ServerUrl}/api/get-records?pageSize=${pageSize}&p=${page}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
export function getRecords(organizationName, page, pageSize, field = "", value = "", sortField = "", sortOrder = "") {
return fetch(`${Setting.ServerUrl}/api/get-records?organizationName=${organizationName}&pageSize=${pageSize}&p=${page}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {

View File

@@ -30,7 +30,7 @@ class CustomGithubCorner extends React.Component {
}
return (
<GithubCorner href={Conf.GithubRepo} size={60} />
<GithubCorner href={"https://github.com/casdoor/casdoor"} size={60} />
);
}
}

View File

@@ -19,7 +19,7 @@ import * as OrganizationBackend from "../../backend/OrganizationBackend";
import * as Setting from "../../Setting";
function OrganizationSelect(props) {
const {onChange, initValue, style, onSelect} = props;
const {onChange, initValue, style, onSelect, withAll, className} = props;
const [organizations, setOrganizations] = React.useState([]);
const [value, setValue] = React.useState(initValue);
@@ -27,15 +27,20 @@ function OrganizationSelect(props) {
if (props.organizations === undefined) {
getOrganizations();
}
}, []);
window.addEventListener("storageOrganizationsChanged", getOrganizations);
return function() {
window.removeEventListener("storageOrganizationsChanged", getOrganizations);
};
}, [value]);
const getOrganizations = () => {
OrganizationBackend.getOrganizationNames("admin")
.then((res) => {
if (res.status === "ok") {
setOrganizations(res.data);
if (initValue === undefined) {
setValue(organizations.length > 0 ? organizations[0] : "");
const selectedValueExist = res.data.filter(organization => organization.name === value).length > 0;
if (initValue === undefined || !selectedValueExist) {
handleOnChange(getOrganizationItems().length > 0 ? getOrganizationItems()[0].value : "");
}
}
});
@@ -46,9 +51,24 @@ function OrganizationSelect(props) {
onChange?.(value);
};
const getOrganizationItems = () => {
const items = [];
organizations.forEach((organization) => items.push(Setting.getOption(organization.displayName, organization.name)));
if (withAll) {
items.unshift({
label: i18next.t("organization:All"),
value: "All",
});
}
return items;
};
return (
<Select
options={organizations.map((organization) => Setting.getOption(organization.displayName, organization.name))}
options={getOrganizationItems()}
virtual={false}
placeholder={i18next.t("login:Please select an organization")}
value={value}
@@ -56,6 +76,7 @@ function OrganizationSelect(props) {
filterOption={(input, option) => (option?.label ?? "").toLowerCase().includes(input.toLowerCase())}
style={style}
onSelect={onSelect}
className={className}
>
</Select>
);

View File

@@ -96,6 +96,7 @@
"Signup items": "Registrierungs Items",
"Signup items - Tooltip": "Items, die Benutzer ausfüllen müssen, wenn sie neue Konten registrieren",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "Die URL der Registrierungsseite wurde in die Zwischenablage kopiert. Bitte fügen Sie sie in einen Inkognito-Tab oder einen anderen Browser ein",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "Die Anwendung erlaubt es nicht, ein neues Konto zu registrieren",
"Token expire": "Token läuft ab",
"Token expire - Tooltip": "Ablaufzeit des Access-Tokens",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "Konto Items",
"Account items - Tooltip": "Elemente auf der persönlichen Einstellungsseite",
"All": "Alle",
"Edit Organization": "Organisation bearbeiten",
"Follow global theme": "Folge dem globalen Theme",
"Init score": "Initialer Score",

View File

@@ -96,6 +96,7 @@
"Signup items": "Signup items",
"Signup items - Tooltip": "Items for users to fill in when registering new accounts",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "The application does not allow to sign up new account",
"Token expire": "Token expire",
"Token expire - Tooltip": "Access token expiration time",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "Account items",
"Account items - Tooltip": "Items in the Personal settings page",
"All": "All",
"Edit Organization": "Edit Organization",
"Follow global theme": "Follow global theme",
"Init score": "Init score",

View File

@@ -96,6 +96,7 @@
"Signup items": "Artículos de registro",
"Signup items - Tooltip": "Elementos para que los usuarios los completen al registrar nuevas cuentas",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "La URL de la página de registro se ha copiado correctamente en el portapapeles. Por favor, péguela en una ventana de incógnito o en otro navegador",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "La aplicación no permite registrarse una cuenta nueva",
"Token expire": "Token expirado",
"Token expire - Tooltip": "Tiempo de expiración del token de acceso",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "Elementos de la cuenta",
"Account items - Tooltip": "Elementos en la página de configuración personal",
"All": "Toda",
"Edit Organization": "Editar organización",
"Follow global theme": "Seguir el tema global",
"Init score": "Puntuación de inicio",

View File

@@ -96,6 +96,7 @@
"Signup items": "Les éléments d'inscription",
"Signup items - Tooltip": "Eléments à remplir par les utilisateurs lors de l'inscription de nouveaux comptes",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "URL de la page d'inscription copiée avec succès dans le presse-papiers, veuillez la coller dans la fenêtre de navigation privée ou dans un autre navigateur",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "L'application ne permet pas de créer un nouveau compte",
"Token expire": "Le jeton expire",
"Token expire - Tooltip": "Temps d'expiration de jeton d'accès",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "Articles de compte",
"Account items - Tooltip": "Éléments de la page des paramètres personnels",
"All": "Tout",
"Edit Organization": "Modifier l'organisation",
"Follow global theme": "Suivre le thème global",
"Init score": "Score initial",

View File

@@ -96,6 +96,7 @@
"Signup items": "Item pendaftaran",
"Signup items - Tooltip": "Item-item yang harus diisi pengguna saat mendaftar untuk akun baru",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "Tautan halaman pendaftaran URL berhasil disalin ke papan klip, silakan tempelkan ke dalam jendela incognito atau browser lain",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "Aplikasi tidak memperbolehkan untuk mendaftar akun baru",
"Token expire": "Token kadaluarsa",
"Token expire - Tooltip": "Waktu kadaluwarsa token akses",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "Item akun",
"Account items - Tooltip": "Item pada halaman pengaturan personal",
"All": "Semua",
"Edit Organization": "Edit Organisasi",
"Follow global theme": "Ikuti tema global",
"Init score": "Skor awal",

View File

@@ -96,6 +96,7 @@
"Signup items": "サインアップアイテム",
"Signup items - Tooltip": "新しいアカウントを登録する際にユーザーが入力するアイテム",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "サインアップページのURLがクリップボードに正常にコピーされました。シークレットウィンドウまたは別のブラウザに貼り付けてください",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "アプリケーションでは新しいアカウントの登録ができません",
"Token expire": "トークンの有効期限が切れました",
"Token expire - Tooltip": "アクセストークンの有効期限",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "アカウントアイテム",
"Account items - Tooltip": "個人設定ページのアイテム",
"All": "全て",
"Edit Organization": "組織の編集",
"Follow global theme": "グローバルテーマに従ってください",
"Init score": "イニットスコア",

View File

@@ -96,6 +96,7 @@
"Signup items": "가입 항목",
"Signup items - Tooltip": "새로운 계정 등록시 사용자가 작성해야하는 항목들",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "가입 페이지 URL이 클립보드에 성공적으로 복사되었습니다. 시크릿 창이나 다른 브라우저에 붙여넣어 주십시오",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "이 어플리케이션은 새 계정 등록을 허용하지 않습니다",
"Token expire": "토큰 만료",
"Token expire - Tooltip": "액세스 토큰 만료 시간",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "계정 항목들",
"Account items - Tooltip": "개인 설정 페이지의 항목들",
"All": "모두",
"Edit Organization": "단체 수정",
"Follow global theme": "글로벌 테마를 따르세요",
"Init score": "처음 점수",

View File

@@ -96,6 +96,7 @@
"Signup items": "Itens de registro",
"Signup items - Tooltip": "Itens para os usuários preencherem ao registrar novas contas",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "URL da página de registro copiada para a área de transferência com sucesso. Cole-a na janela anônima ou em outro navegador",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "A aplicação não permite o registro de novas contas",
"Token expire": "Expiração do Token",
"Token expire - Tooltip": "Tempo de expiração do token de acesso",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "Itens da Conta",
"Account items - Tooltip": "Itens na página de Configurações Pessoais",
"All": "Todos",
"Edit Organization": "Editar Organização",
"Follow global theme": "Seguir tema global",
"Init score": "Pontuação inicial",

View File

@@ -96,6 +96,7 @@
"Signup items": "Элементы регистрации",
"Signup items - Tooltip": "Элементы, которые пользователи должны заполнить при регистрации новых аккаунтов",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "Успешно скопирован URL страницы регистрации в буфер обмена, пожалуйста, вставьте его в режиме инкогнито или в другом браузере",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "Приложение не позволяет зарегистрироваться новому аккаунту",
"Token expire": "Срок действия токена истекает",
"Token expire - Tooltip": "Время истечения токена доступа",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "Элементы учета",
"Account items - Tooltip": "Элементы на странице личных настроек",
"All": "Все",
"Edit Organization": "Редактировать организацию",
"Follow global theme": "Следуйте глобальной теме",
"Init score": "Начальный балл",

View File

@@ -96,6 +96,7 @@
"Signup items": "Các mục đăng ký",
"Signup items - Tooltip": "Các thông tin cần được người dùng điền khi đăng ký tài khoản mới",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "Đã sao chép thành công đường dẫn trang đăng ký vào clipboard, vui lòng dán nó vào cửa sổ ẩn danh hoặc trình duyệt khác",
"Tags - Tooltip": "Only users with the tag that is listed in the application tags can login",
"The application does not allow to sign up new account": "Ứng dụng không cho phép đăng ký tài khoản mới",
"Token expire": "Mã thông báo hết hạn",
"Token expire - Tooltip": "Thời gian hết hạn của mã truy cập",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "Mục tài khoản",
"Account items - Tooltip": "Các mục trong trang Cài đặt cá nhân",
"All": "Tất cả",
"Edit Organization": "Chỉnh sửa tổ chức",
"Follow global theme": "Theo chủ đề toàn cầu",
"Init score": "Điểm khởi tạo",

View File

@@ -96,6 +96,7 @@
"Signup items": "注册项",
"Signup items - Tooltip": "注册用户注册时需要填写的项目",
"Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser": "注册页面URL已成功复制到剪贴板请粘贴到当前浏览器的隐身模式窗口或另一个浏览器访问",
"Tags - Tooltip": "用户的标签在应用的标签集合中时,用户才可以登录该应用",
"The application does not allow to sign up new account": "该应用不允许注册新账户",
"Token expire": "Access Token过期",
"Token expire - Tooltip": "Access Token过期时间",
@@ -466,6 +467,7 @@
"organization": {
"Account items": "个人页设置项",
"Account items - Tooltip": "用户的个人设置页面中可配置的选项",
"All": "全部",
"Edit Organization": "编辑组织",
"Follow global theme": "使用全局默认主题",
"Init score": "初始积分",