sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
warehost/cmd/warehost-ftp/auth.go

36 lines
747 B
Go
Raw Permalink Normal View History

package main
import (
"github.com/jinzhu/gorm"
liblog "dev.sum7.eu/sum7/warehost/lib/log"
libpassword "dev.sum7.eu/sum7/warehost/lib/password"
system "dev.sum7.eu/sum7/warehost/system"
)
type WarehostAuth struct {
db *gorm.DB
}
2016-12-20 00:35:03 +01:00
func (auth WarehostAuth) CheckPasswd(user, pass string) (returndata bool, err error) {
returndata = false
var login = system.Login{Username: user}
2016-12-20 00:35:03 +01:00
auth.db.Where("mail = ?", user).First(&login)
if login.ID <= 0 {
liblog.Log.Warn("user not found")
return
}
if login.Active {
output, _ := libpassword.Validate(login.Password, pass)
if output {
returndata = true
liblog.Log.Info("done")
} else {
liblog.Log.Warn("wrong password")
}
} else {
liblog.Log.Warn("not active")
}
return
}