32 lines
511 B
Go
32 lines
511 B
Go
package models
|
|
|
|
import (
|
|
"log"
|
|
|
|
"list_app/db"
|
|
)
|
|
|
|
type UserValue int
|
|
|
|
const (
|
|
Pass UserValue = iota + 1
|
|
OmdbKey
|
|
TwitchClientID
|
|
TwitchClientSecret
|
|
)
|
|
|
|
func GetValue(id UserValue) (string, bool) {
|
|
var value string
|
|
err := db.Pool.QueryRow("SELECT value FROM userData where id = ?;", int(id)).Scan(&value)
|
|
if err != nil {
|
|
log.Println(err)
|
|
return "", false
|
|
}
|
|
return value, true
|
|
}
|
|
|
|
func CheckPassword(pass string) bool {
|
|
password, ok := GetValue(Pass)
|
|
return ok && password != "" && pass == password
|
|
}
|