mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat: creation of service account (#44913)
* feat: creation of service account * added back button for the details page * refactor: remove unused file, renamed fields * oppps
This commit is contained in:
@@ -71,8 +71,11 @@ func (api *ServiceAccountsAPI) CreateServiceAccount(c *models.ReqContext) respon
|
||||
case err != nil:
|
||||
return response.Error(http.StatusInternalServerError, "Failed to create service account", err)
|
||||
}
|
||||
|
||||
return response.JSON(http.StatusCreated, user)
|
||||
result := models.UserIdDTO{
|
||||
Message: "Service account created",
|
||||
Id: user.Id,
|
||||
}
|
||||
return response.JSON(http.StatusCreated, result)
|
||||
}
|
||||
|
||||
func (api *ServiceAccountsAPI) DeleteServiceAccount(ctx *models.ReqContext) response.Response {
|
||||
|
||||
@@ -27,9 +27,10 @@ func NewServiceAccountsStore(store *sqlstore.SQLStore) *ServiceAccountsStoreImpl
|
||||
|
||||
func (s *ServiceAccountsStoreImpl) CreateServiceAccount(ctx context.Context, sa *serviceaccounts.CreateServiceaccountForm) (user *models.User, err error) {
|
||||
// create a new service account - "user" with empty permissions
|
||||
generatedLogin := "Service-Account-" + uuid.New().String()
|
||||
cmd := models.CreateUserCommand{
|
||||
Login: "Service-Account-" + uuid.New().String(),
|
||||
Name: sa.Name + "-Service-Account-" + uuid.New().String(),
|
||||
Login: generatedLogin,
|
||||
Name: sa.Name,
|
||||
OrgId: sa.OrgID,
|
||||
IsServiceAccount: true,
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ type ServiceAccount struct {
|
||||
}
|
||||
|
||||
type CreateServiceaccountForm struct {
|
||||
OrgID int64 `json:"-"`
|
||||
Name string `json:"name" binding:"Required"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Description string `json:"description"`
|
||||
OrgID int64 `json:"-"`
|
||||
Name string `json:"name" binding:"Required"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user