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

45 lines
989 B
Go
Raw Normal View History

2023-02-28 14:20:26 +08:00
package api
2021-12-27 18:22:32 +08:00
import (
2023-02-28 14:20:26 +08:00
"OpenIM/internal/api/a2r"
2023-02-23 19:15:30 +08:00
"OpenIM/pkg/common/config"
2023-03-08 17:29:03 +08:00
"OpenIM/pkg/discoveryregistry"
2023-02-28 11:38:05 +08:00
auth "OpenIM/pkg/proto/auth"
2021-12-27 18:22:32 +08:00
"context"
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-08 17:29:03 +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
}