|
@@ -4,15 +4,16 @@ import (
|
|
|
"context"
|
|
|
"errors"
|
|
|
"wechat-api/ent"
|
|
|
+ tokenModel "wechat-api/ent/token"
|
|
|
)
|
|
|
|
|
|
// CheckDesktopAuth 检查token是否合法同时返回token实例
|
|
|
func CheckDesktopAuth(tokenStr string, client *ent.Client) (*ent.Token, error) {
|
|
|
if tokenStr == "" {
|
|
|
- return nil, errors.New("check auth failed")
|
|
|
+ return nil, errors.New("auth cannot be null")
|
|
|
}
|
|
|
-
|
|
|
- token, err := client.Token.Query().Where().Only(context.Background())
|
|
|
+
|
|
|
+ token, err := client.Token.Query().Where(tokenModel.Token(tokenStr)).Only(context.Background())
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|