Fixed nil password causing invalid dereferences

This commit is contained in:
BetaPictoris
2023-10-27 16:02:47 -07:00
parent 667cf731fd
commit a99d63ab12
2 changed files with 3 additions and 3 deletions

No files matched your search

+1 -1
View File
@@ -169,7 +169,7 @@ type User struct {
ID int `gorm:"primary_key"` ID int `gorm:"primary_key"`
CreatedAt time.Time CreatedAt time.Time
Name string `gorm:"not null; unique_index" sql:"default: null"` Name string `gorm:"not null; unique_index" sql:"default: null"`
Password string `gorm:"not null" sql:"default: null"` Password string `sql:"default: null"`
LastFMSession string `sql:"default: null"` LastFMSession string `sql:"default: null"`
ListenBrainzURL string `sql:"default: null"` ListenBrainzURL string `sql:"default: null"`
ListenBrainzToken string `sql:"default: null"` ListenBrainzToken string `sql:"default: null"`
+2 -2
View File
@@ -146,9 +146,9 @@ func (c *Controller) WithUser(next http.Handler) http.Handler {
} }
} }
var credsOk bool var credsOk bool
if tokenAuth && !newLDAPUser { if tokenAuth && !newLDAPUser && user != nil {
credsOk = checkCredsToken(user.Password, token, salt) credsOk = checkCredsToken(user.Password, token, salt)
} else if !newLDAPUser { } else if !newLDAPUser && user != nil {
credsOk = checkCredsBasic(user.Password, password) credsOk = checkCredsBasic(user.Password, password)
} }
if !credsOk { if !credsOk {