- localpass added.
This commit is contained in:
37
business/jxcallback/auth/localpass/localpass.go
Normal file
37
business/jxcallback/auth/localpass/localpass.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package localpass
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals/gormdb"
|
||||
)
|
||||
|
||||
const (
|
||||
LoginType = "localpass"
|
||||
)
|
||||
|
||||
type Auther struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
auth.RegisterAuther(LoginType, new(Auther))
|
||||
}
|
||||
|
||||
func (a *Auther) Login(uname, password string) (err error) {
|
||||
user := &model.JxBackendUser{}
|
||||
db := gormdb.GetDB()
|
||||
if err = db.Where("uname = ?", uname).First(user).Error; err == nil {
|
||||
if fmt.Sprintf("%x", md5.Sum([]byte(password))) == user.UPass {
|
||||
return nil
|
||||
}
|
||||
err = auth.ErrUIDAndPassNotMatch
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *Auther) Logout(openid string) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user