mirror of
https://github.com/netbirdio/netbird.git
synced 2025-04-12 21:48:26 +02:00
Fix panic on empty username for invites (#1334)
Validate email and user are not empty
This commit is contained in:
parent
d1a323fa9d
commit
dc05102b8f
@ -155,9 +155,14 @@ func (h *UsersHandler) CreateUser(w http.ResponseWriter, r *http.Request) {
|
|||||||
email = *req.Email
|
email = *req.Email
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name := ""
|
||||||
|
if req.Name != nil {
|
||||||
|
name = *req.Name
|
||||||
|
}
|
||||||
|
|
||||||
newUser, err := h.accountManager.CreateUser(account.Id, user.Id, &server.UserInfo{
|
newUser, err := h.accountManager.CreateUser(account.Id, user.Id, &server.UserInfo{
|
||||||
Email: email,
|
Email: email,
|
||||||
Name: *req.Name,
|
Name: name,
|
||||||
Role: req.Role,
|
Role: req.Role,
|
||||||
AutoGroups: req.AutoGroups,
|
AutoGroups: req.AutoGroups,
|
||||||
IsServiceUser: req.IsServiceUser,
|
IsServiceUser: req.IsServiceUser,
|
||||||
|
@ -258,6 +258,14 @@ func (am *DefaultAccountManager) inviteNewUser(accountID, userID string, invite
|
|||||||
return nil, fmt.Errorf("provided user update is nil")
|
return nil, fmt.Errorf("provided user update is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case invite.Name == "":
|
||||||
|
return nil, status.Errorf(status.InvalidArgument, "name can't be empty")
|
||||||
|
case invite.Email == "":
|
||||||
|
return nil, status.Errorf(status.InvalidArgument, "email can't be empty")
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
account, err := am.Store.GetAccount(accountID)
|
account, err := am.Store.GetAccount(accountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(status.NotFound, "account %s doesn't exist", accountID)
|
return nil, status.Errorf(status.NotFound, "account %s doesn't exist", accountID)
|
||||||
|
Loading…
Reference in New Issue
Block a user