19 lines
497 B
Go
19 lines
497 B
Go
package auth
|
|
|
|
import (
|
|
"golang.org/x/crypto/bcrypt"
|
|
log "github.com/sirupsen/logrus"
|
|
"reichard.io/imagini/graph/model"
|
|
)
|
|
|
|
func authenticateLocalUser(user model.User, pw string) bool {
|
|
bPassword :=[]byte(pw)
|
|
err := bcrypt.CompareHashAndPassword([]byte(*user.Password), bPassword)
|
|
if err == nil {
|
|
log.Info("[auth] Authentication successfull: ", user.Username)
|
|
return true
|
|
}
|
|
log.Warn("[auth] Authentication failed: ", user.Username)
|
|
return false
|
|
}
|