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

46 lines
1.1 KiB

2 years ago
package api
3 years ago
import (
"context"
2 years ago
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
auth "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
"github.com/gin-gonic/gin"
3 years ago
)
2 years ago
var _ context.Context // 解决goland编辑器bug
3 years ago
2 years ago
func NewAuth(c discoveryregistry.SvcDiscoveryRegistry) *Auth {
return &Auth{c: c}
3 years ago
}
2 years ago
type Auth struct {
2 years ago
c discoveryregistry.SvcDiscoveryRegistry
2 years ago
}
3 years ago
2 years ago
func (o *Auth) client(ctx context.Context) (auth.AuthClient, error) {
conn, err := o.c.GetConn(ctx, config.Config.RpcRegisterName.OpenImAuthName)
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
}