Skip to content

Commit 2d60f60

Browse files
committed
changed account to userID in config and validate request
1 parent f3c320b commit 2d60f60

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

config/config.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ type Admin struct {
4545

4646
// OperationConfig holds the operation mode config
4747
type OperationConfig struct {
48-
Mode int `json:"mode" yaml:"mode"`
49-
Email string `json:"email" yaml:"email"`
50-
Key string `json:"key" yaml:"key"`
48+
Mode int `json:"mode" yaml:"mode"`
49+
UserID string `json:"userId" yaml:"userId"`
50+
Key string `json:"key" yaml:"key"`
5151
}
5252

5353
// AdminUser holds the user credentials and scope

model/validate.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package model
22

33
// RegisterRequest is the struct which carries the space cloud register payload
44
type RegisterRequest struct {
5-
ID string `json:"id"` // This is the space cloud id
6-
Key string `json:"key"`
7-
Account string `json:"account"`
8-
Mode int `json:"mode"`
5+
ID string `json:"id"` // This is the space cloud id
6+
Key string `json:"key"`
7+
UserID string `json:"userId"`
8+
Mode int `json:"mode"`
99
}
1010

1111
// RegisterResponse is the response to the register request

utils/admin/admin.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ func (m *Manager) SetOperationMode(op *config.OperationConfig) error {
4343
m.lock.Lock()
4444
defer m.lock.Unlock()
4545

46-
if op.Mode > 0 && (op.Email == "" || op.Key == "") {
46+
if op.Mode > 0 && (op.UserID == "" || op.Key == "") {
4747
return errors.New("Invalid operation setting provided")
4848
}
4949

5050
if op.Mode > 0 {
5151
// Start the validation process for higher op modes
52-
if err := m.validator.startValidation(m.nodeID, op.Email, op.Key, op.Mode); err != nil {
52+
if err := m.validator.startValidation(m.nodeID, op.UserID, op.Key, op.Mode); err != nil {
5353
return err
5454
}
5555
} else {

utils/admin/validate.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ func newValidator(cb func()) *validator {
2424
}
2525

2626
// Start starts the validation process
27-
func (v *validator) startValidation(id, account, key string, mode int) error {
27+
func (v *validator) startValidation(id, userID, key string, mode int) error {
2828
// Set validation status to active
2929
v.setActive(true)
3030

31-
if err := v.registerSpaceCloud(id, account, key, mode); err != nil {
31+
if err := v.registerSpaceCloud(id, userID, key, mode); err != nil {
3232
return err
3333
}
3434

@@ -54,7 +54,7 @@ func (v *validator) startValidation(id, account, key string, mode int) error {
5454
return
5555
}
5656

57-
if err := v.registerSpaceCloud(id, account, key, mode); err != nil {
57+
if err := v.registerSpaceCloud(id, userID, key, mode); err != nil {
5858
log.Println("Validate: Error -", err)
5959
} else {
6060
timer = time.Now()

utils/admin/websocket.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ func (v *validator) connect(url string) error {
3434
return nil
3535
}
3636

37-
func (v *validator) write(id, account, key string, mode int) error {
38-
req := &model.RegisterRequest{ID: id, Account: account, Key: key, Mode: mode}
37+
func (v *validator) write(id, userID, key string, mode int) error {
38+
req := &model.RegisterRequest{ID: id, UserID: userID, Key: key, Mode: mode}
3939
msg := &model.Message{Type: utils.TypeRegisterRequest, Data: req}
4040
return v.socket.WriteJSON(msg)
4141
}
@@ -69,13 +69,13 @@ func (v *validator) routineRead() error {
6969
}
7070
}
7171

72-
func (v *validator) registerSpaceCloud(id, account, secret string, mode int) error {
72+
func (v *validator) registerSpaceCloud(id, userID, secret string, mode int) error {
7373
err := v.connect(url)
7474
if err != nil {
7575
return err
7676
}
7777

78-
err = v.write(id, account, secret, mode)
78+
err = v.write(id, userID, secret, mode)
7979
if err != nil {
8080
return err
8181
}

0 commit comments

Comments
 (0)