Add password field to link shares

This commit is contained in:
kolaente 2021-04-11 11:32:14 +02:00
parent 6a927c0703
commit 4cf79625f8
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,43 @@
// Vikunja is a to-do list application to facilitate your life.
// Copyright 2018-2021 Vikunja and contributors. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public Licensee as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public Licensee for more details.
//
// You should have received a copy of the GNU Affero General Public Licensee
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package migration
import (
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)
type linkShares20210411113105 struct {
Password string `xorm:"text null"`
}
func (linkShares20210411113105) TableName() string {
return "link_shares"
}
func init() {
migrations = append(migrations, &xormigrate.Migration{
ID: "20210411113105",
Description: "Add password field to link shares",
Migrate: func(tx *xorm.Engine) error {
return tx.Sync2(linkShares20210411113105{})
},
Rollback: func(tx *xorm.Engine) error {
return nil
},
})
}

View File

@ -49,9 +49,12 @@ type LinkSharing struct {
// The right this list is shared with. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"bigint INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// The kind of this link. 0 = undefined, 1 = without password, 2 = with password (currently not implemented).
// The kind of this link. 0 = undefined, 1 = without password, 2 = with password.
SharingType SharingType `xorm:"bigint INDEX not null default 0" json:"sharing_type" valid:"length(0|2)" maximum:"2" default:"0"`
// The password of this link share. You can only set it, not retrieve it after the link share has been created.
Password string `xorm:"text null" json:"password"`
// The user who shared this list
SharedBy *user.User `xorm:"-" json:"shared_by"`
SharedByID int64 `xorm:"bigint INDEX not null" json:"-"`
@ -156,6 +159,7 @@ func (share *LinkSharing) ReadOne(s *xorm.Session, a web.Auth) (err error) {
if !exists {
return ErrListShareDoesNotExist{ID: share.ID, Hash: share.Hash}
}
share.Password = ""
return
}
@ -212,6 +216,7 @@ func (share *LinkSharing) ReadAll(s *xorm.Session, a web.Auth, search string, pa
for _, s := range shares {
s.SharedBy = users[s.SharedByID]
s.Password = ""
}
// Total count