🐛 Fix back compability of draft state
This commit is contained in:
parent
5b8eff7a42
commit
d7113b5237
@ -43,7 +43,7 @@ func FilterArticleWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func FilterArticleDraft(tx *gorm.DB) *gorm.DB {
|
func FilterArticleDraft(tx *gorm.DB) *gorm.DB {
|
||||||
return tx.Where("is_draft = ?", false)
|
return tx.Where("is_draft = ? OR is_draft IS NULL", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetArticleWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (models.Article, error) {
|
func GetArticleWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (models.Article, error) {
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package services
|
|
||||||
|
|
||||||
import "golang.org/x/crypto/bcrypt"
|
|
||||||
|
|
||||||
func HashPassword(raw string) string {
|
|
||||||
data, _ := bcrypt.GenerateFromPassword([]byte(raw), 12)
|
|
||||||
return string(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func VerifyPassword(text string, password string) bool {
|
|
||||||
return bcrypt.CompareHashAndPassword([]byte(password), []byte(text)) == nil
|
|
||||||
}
|
|
@ -51,7 +51,7 @@ func FilterPostWithAuthorDraft(tx *gorm.DB, uid uint) *gorm.DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func FilterPostDraft(tx *gorm.DB) *gorm.DB {
|
func FilterPostDraft(tx *gorm.DB) *gorm.DB {
|
||||||
return tx.Where("is_draft = ?", false)
|
return tx.Where("is_draft = ? OR is_draft IS NULL", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPostWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (models.Post, error) {
|
func GetPostWithAlias(tx *gorm.DB, alias string, ignoreLimitation ...bool) (models.Post, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user