Convert to go
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user