mirror of
https://github.com/usememos/memos.git
synced 2025-04-03 20:31:10 +02:00
chore: update list workspace settings
This commit is contained in:
parent
cf7718f8dc
commit
bb076ce486
@ -4,8 +4,8 @@ var authenticationAllowlistMethods = map[string]bool{
|
|||||||
"/memos.api.v1.WorkspaceService/GetWorkspaceProfile": true,
|
"/memos.api.v1.WorkspaceService/GetWorkspaceProfile": true,
|
||||||
"/memos.api.v1.WorkspaceSettingService/GetWorkspaceSetting": true,
|
"/memos.api.v1.WorkspaceSettingService/GetWorkspaceSetting": true,
|
||||||
"/memos.api.v1.WorkspaceSettingService/ListWorkspaceSettings": true,
|
"/memos.api.v1.WorkspaceSettingService/ListWorkspaceSettings": true,
|
||||||
"/memos.api.v1.IdentityProviderService/ListIdentityProviders": true,
|
|
||||||
"/memos.api.v1.IdentityProviderService/GetIdentityProvider": true,
|
"/memos.api.v1.IdentityProviderService/GetIdentityProvider": true,
|
||||||
|
"/memos.api.v1.IdentityProviderService/ListIdentityProviders": true,
|
||||||
"/memos.api.v1.AuthService/GetAuthStatus": true,
|
"/memos.api.v1.AuthService/GetAuthStatus": true,
|
||||||
"/memos.api.v1.AuthService/SignIn": true,
|
"/memos.api.v1.AuthService/SignIn": true,
|
||||||
"/memos.api.v1.AuthService/SignInWithSSO": true,
|
"/memos.api.v1.AuthService/SignInWithSSO": true,
|
||||||
@ -14,12 +14,9 @@ var authenticationAllowlistMethods = map[string]bool{
|
|||||||
"/memos.api.v1.UserService/GetUser": true,
|
"/memos.api.v1.UserService/GetUser": true,
|
||||||
"/memos.api.v1.UserService/GetUserAvatarBinary": true,
|
"/memos.api.v1.UserService/GetUserAvatarBinary": true,
|
||||||
"/memos.api.v1.UserService/SearchUsers": true,
|
"/memos.api.v1.UserService/SearchUsers": true,
|
||||||
"/memos.api.v1.MemoService/ListMemos": true,
|
|
||||||
"/memos.api.v1.MemoService/GetMemo": true,
|
"/memos.api.v1.MemoService/GetMemo": true,
|
||||||
|
"/memos.api.v1.MemoService/ListMemos": true,
|
||||||
"/memos.api.v1.MemoService/SearchMemos": true,
|
"/memos.api.v1.MemoService/SearchMemos": true,
|
||||||
"/memos.api.v1.MemoService/ListMemoResources": true,
|
|
||||||
"/memos.api.v1.MemoService/ListMemoRelations": true,
|
|
||||||
"/memos.api.v1.MemoService/ListMemoComments": true,
|
|
||||||
"/memos.api.v1.MarkdownService/GetLinkMetadata": true,
|
"/memos.api.v1.MarkdownService/GetLinkMetadata": true,
|
||||||
"/memos.api.v1.ResourceService/GetResourceBinary": true,
|
"/memos.api.v1.ResourceService/GetResourceBinary": true,
|
||||||
}
|
}
|
||||||
@ -31,6 +28,7 @@ func isUnauthorizeAllowedMethod(fullMethodName string) bool {
|
|||||||
|
|
||||||
var allowedMethodsOnlyForAdmin = map[string]bool{
|
var allowedMethodsOnlyForAdmin = map[string]bool{
|
||||||
"/memos.api.v1.UserService/CreateUser": true,
|
"/memos.api.v1.UserService/CreateUser": true,
|
||||||
|
"/memos.api.v1.WorkspaceSettingService/SetWorkspaceSetting": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// isOnlyForAdminAllowedMethod returns true if the method is allowed to be called only by admin.
|
// isOnlyForAdminAllowedMethod returns true if the method is allowed to be called only by admin.
|
||||||
|
@ -13,7 +13,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (s *APIV1Service) ListWorkspaceSettings(ctx context.Context, _ *v1pb.ListWorkspaceSettingsRequest) (*v1pb.ListWorkspaceSettingsResponse, error) {
|
func (s *APIV1Service) ListWorkspaceSettings(ctx context.Context, _ *v1pb.ListWorkspaceSettingsRequest) (*v1pb.ListWorkspaceSettingsResponse, error) {
|
||||||
workspaceSettings, err := s.Store.ListWorkspaceSettings(ctx, &store.FindWorkspaceSetting{})
|
user, err := getCurrentUser(ctx, s.Store)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
workspaceSettingFind := &store.FindWorkspaceSetting{}
|
||||||
|
if user == nil || user.Role == store.RoleUser {
|
||||||
|
workspaceSettingFind.Name = storepb.WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL.String()
|
||||||
|
}
|
||||||
|
workspaceSettings, err := s.Store.ListWorkspaceSettings(ctx, workspaceSettingFind)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to get workspace setting: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to get workspace setting: %v", err)
|
||||||
}
|
}
|
||||||
@ -35,9 +44,8 @@ func (s *APIV1Service) GetWorkspaceSetting(ctx context.Context, request *v1pb.Ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "invalid workspace setting name: %v", err)
|
return nil, status.Errorf(codes.InvalidArgument, "invalid workspace setting name: %v", err)
|
||||||
}
|
}
|
||||||
settingKey := storepb.WorkspaceSettingKey(storepb.WorkspaceSettingKey_value[settingKeyString])
|
|
||||||
workspaceSetting, err := s.Store.GetWorkspaceSetting(ctx, &store.FindWorkspaceSetting{
|
workspaceSetting, err := s.Store.GetWorkspaceSetting(ctx, &store.FindWorkspaceSetting{
|
||||||
Name: settingKey.String(),
|
Name: settingKeyString,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to get workspace setting: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to get workspace setting: %v", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user