mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Don't hash blank password. Treat blank username/pw as no credentials
This commit is contained in:
@@ -24,7 +24,12 @@ func Set(key string, value interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetPassword(value string) {
|
func SetPassword(value string) {
|
||||||
Set(Password, hashPassword(value))
|
// if blank, don't bother hashing; we want it to be blank
|
||||||
|
if value == "" {
|
||||||
|
Set(Password, "")
|
||||||
|
} else {
|
||||||
|
Set(Password, hashPassword(value))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Write() error {
|
func Write() error {
|
||||||
@@ -76,7 +81,14 @@ func GetCredentials() (string, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func HasCredentials() bool {
|
func HasCredentials() bool {
|
||||||
return viper.IsSet(Username) && viper.IsSet(Password)
|
if !viper.IsSet(Username) || !viper.IsSet(Password) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
username := GetUsername()
|
||||||
|
pwHash := GetPasswordHash()
|
||||||
|
|
||||||
|
return username != "" && pwHash != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func hashPassword(password string) string {
|
func hashPassword(password string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user