Commit 63d657e2 authored by Kevin Lyda's avatar Kevin Lyda
Browse files

Limit CREATE to admins

parent 3ac6fa2c
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -46,13 +46,22 @@ const (
)

// CreateFolder creates a new folder.
func CreateFolder(options storage.CreateFolderParams) error {
func CreateFolder(login string, options storage.CreateFolderParams) error {
	if !IsAlphaNum(options.Name) {
		return errors.New("folder can only have letters and numbers")
	}
	options.Name = strings.ToUpper(options.Name)

	ctx := storage.Context()
	admin, err := this.Q.IsUserAdmin(ctx, login)
	if err != nil {
		return err
	}
	if admin != 1 {
		return errors.New("only admins can create folders")
	}

	options.Name = strings.ToUpper(options.Name)

	return this.Q.CreateFolder(ctx, options)
}

+2 −4
Original line number Diff line number Diff line
@@ -231,9 +231,7 @@ The folder-name is limited to 25 letters and must not include spaces or
characters that are also invalid  in  filenames  (this  is  because  the
folder is stored in a file name created with the folder name).

NOTE:  Creation  of folders may be a restricted command if the installer
has  elected  to  install  it  as  such.   This  is  done  by  modifying
BULLCOM.CLD.`,
NOTE:  Creation  of folders is a privileged command.`,
		Action:  ActionCreate,
		MinArgs: 1,
		MaxArgs: 1,
+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ func ActionCreate(cmd *dclish.Command) error {
	if options.Description == "" || len(options.Description) > 53 {
		return errors.New("description must exist and be under 53 characters")
	}
	err := folders.CreateFolder(options)
	err := folders.CreateFolder(this.User.Login, options)
	return err
}