1.重构认证方式的代码,方便未来扩展 2.补充测试用例

This commit is contained in:
lanrenwo
2022-06-06 21:25:19 +08:00
parent c38f1e9b8c
commit b06c035cce
6 changed files with 149 additions and 76 deletions

15
server/dbdata/userauth.go Normal file
View File

@@ -0,0 +1,15 @@
package dbdata
import "reflect"
var authRegistry = make(map[string]reflect.Type)
type IUserAuth interface {
checkData(authData map[string]interface{}) error
checkUser(name string, pwd string, authData map[string]interface{}) error
}
func makeInstance(name string) interface{} {
v := reflect.New(authRegistry[name]).Elem()
return v.Interface()
}