You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/api/auth.go

45 lines
967 B

2 years ago
package api
3 years ago
import (
2 years ago
"OpenIM/internal/api/a2r"
2 years ago
"OpenIM/pkg/common/config"
2 years ago
auth "OpenIM/pkg/proto/auth"
3 years ago
"context"
2 years ago
"github.com/OpenIMSDK/openKeeper"
"github.com/gin-gonic/gin"
3 years ago
)
2 years ago
var _ context.Context // 解决goland编辑器bug
3 years ago
2 years ago
func NewAuth(zk *openKeeper.ZkClient) *Auth {
return &Auth{zk: zk}
3 years ago
}
2 years ago
type Auth struct {
zk *openKeeper.ZkClient
}
3 years ago
2 years ago
func (o *Auth) client() (auth.AuthClient, error) {
2 years ago
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName, nil)
3 years ago
if err != nil {
2 years ago
return nil, err
3 years ago
}
2 years ago
return auth.NewAuthClient(conn), nil
3 years ago
}
3 years ago
2 years ago
func (o *Auth) UserRegister(c *gin.Context) {
2 years ago
//a2r.Call(auth.AuthClient.UserRegister, o.client, c) // todo
3 years ago
}
2 years ago
2 years ago
func (o *Auth) UserToken(c *gin.Context) {
a2r.Call(auth.AuthClient.UserToken, o.client, c)
2 years ago
}
2 years ago
2 years ago
func (o *Auth) ParseToken(c *gin.Context) {
a2r.Call(auth.AuthClient.ParseToken, o.client, c)
2 years ago
}
2 years ago
2 years ago
func (o *Auth) ForceLogout(c *gin.Context) {
a2r.Call(auth.AuthClient.ForceLogout, o.client, c)
2 years ago
}