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.
45 lines
992 B
45 lines
992 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"
|
||
2 years ago
|
"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 (a *Auth) getGroupClient() (auth.AuthClient, error) {
|
||
|
conn, err := a.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName)
|
||
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 (a *Auth) UserRegister(c *gin.Context) {
|
||
|
a2r.Call(auth.AuthClient.UserRegister, a.getGroupClient, c)
|
||
3 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
func (a *Auth) UserToken(c *gin.Context) {
|
||
|
a2r.Call(auth.AuthClient.UserToken, a.getGroupClient, c)
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
func (a *Auth) ParseToken(c *gin.Context) {
|
||
|
a2r.Call(auth.AuthClient.ParseToken, a.getGroupClient, c)
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
func (a *Auth) ForceLogout(c *gin.Context) {
|
||
|
a2r.Call(auth.AuthClient.ForceLogout, a.getGroupClient, c)
|
||
2 years ago
|
}
|