mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
feat: check if the secret in config/share.yml has been changed during registration.
This commit is contained in:
parent
e76e02fdba
commit
ca12e25e91
@ -49,6 +49,10 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultSecret = "openIM123"
|
||||
)
|
||||
|
||||
type userServer struct {
|
||||
pbuser.UnimplementedUserServer
|
||||
online cache.OnlineCache
|
||||
@ -273,6 +277,10 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
|
||||
if len(req.Users) == 0 {
|
||||
return nil, errs.ErrArgs.WrapMsg("users is empty")
|
||||
}
|
||||
// check if secret is changed
|
||||
if s.config.Share.Secret == defaultSecret {
|
||||
return nil, servererrs.ErrSecretNotChanged.Wrap()
|
||||
}
|
||||
|
||||
if err = authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil {
|
||||
return nil, err
|
||||
|
@ -38,6 +38,9 @@ const (
|
||||
// General error codes.
|
||||
const (
|
||||
NoError = 0 // No error
|
||||
|
||||
SecretNotChangedError = 50 // secret not changed
|
||||
|
||||
DatabaseError = 90002 // Database error (redis/mysql, etc.)
|
||||
NetworkError = 90004 // Network error
|
||||
DataError = 90007 // Data error
|
||||
|
@ -17,6 +17,8 @@ package servererrs
|
||||
import "github.com/openimsdk/tools/errs"
|
||||
|
||||
var (
|
||||
ErrSecretNotChanged = errs.NewCodeError(SecretNotChangedError, "secret not changed, please change secret in config/share.yml for security reasons")
|
||||
|
||||
ErrDatabase = errs.NewCodeError(DatabaseError, "DatabaseError")
|
||||
ErrNetwork = errs.NewCodeError(NetworkError, "NetworkError")
|
||||
ErrCallback = errs.NewCodeError(CallbackError, "CallbackError")
|
||||
|
Loading…
x
Reference in New Issue
Block a user