Files
open-im-server/internal/api/auth.go
T

46 lines
1.1 KiB
Go
Raw Normal View History

2023-02-28 14:20:26 +08:00
package api
2021-12-27 18:22:32 +08:00
import (
"context"
2023-03-17 11:41:20 +08:00
2023-03-17 11:27:34 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
2023-03-16 10:46:06 +08:00
"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"
2022-08-07 22:37:27 +08:00
"github.com/gin-gonic/gin"
2021-12-27 18:22:32 +08:00
)
2023-02-28 11:38:05 +08:00
var _ context.Context // 解决goland编辑器bug
2021-12-28 18:03:51 +08:00
2023-03-08 17:29:03 +08:00
func NewAuth(c discoveryregistry.SvcDiscoveryRegistry) *Auth {
return &Auth{c: c}
2021-12-27 18:22:32 +08:00
}
2023-02-28 11:38:05 +08:00
type Auth struct {
2023-03-08 17:29:03 +08:00
c discoveryregistry.SvcDiscoveryRegistry
2023-02-28 11:38:05 +08:00
}
2021-12-27 18:22:32 +08:00
2023-03-02 14:41:59 +08:00
func (o *Auth) client() (auth.AuthClient, error) {
2023-03-09 13:26:58 +08:00
conn, err := o.c.GetConn(config.Config.RpcRegisterName.OpenImAuthName)
2021-12-27 18:22:32 +08:00
if err != nil {
2023-02-28 11:38:05 +08:00
return nil, err
2021-12-27 18:22:32 +08:00
}
2023-02-28 11:38:05 +08:00
return auth.NewAuthClient(conn), nil
2021-12-27 18:22:32 +08:00
}
2022-05-10 09:45:55 +08:00
2023-03-02 14:41:59 +08:00
func (o *Auth) UserRegister(c *gin.Context) {
2023-03-03 18:59:28 +08:00
//a2r.Call(auth.AuthClient.UserRegister, o.client, c) // todo
2022-05-10 09:45:55 +08:00
}
2022-06-06 20:39:45 +08:00
2023-03-02 14:41:59 +08:00
func (o *Auth) UserToken(c *gin.Context) {
a2r.Call(auth.AuthClient.UserToken, o.client, c)
2023-02-28 11:38:05 +08:00
}
2022-06-07 11:42:15 +08:00
2023-03-02 14:41:59 +08:00
func (o *Auth) ParseToken(c *gin.Context) {
a2r.Call(auth.AuthClient.ParseToken, o.client, c)
2023-02-28 11:38:05 +08:00
}
2022-06-06 20:39:45 +08:00
2023-03-02 14:41:59 +08:00
func (o *Auth) ForceLogout(c *gin.Context) {
a2r.Call(auth.AuthClient.ForceLogout, o.client, c)
2022-06-06 20:39:45 +08:00
}