Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Commit

Permalink
Clarified errors in request process
Browse files Browse the repository at this point in the history
  • Loading branch information
Caiyeon committed Sep 19, 2017
1 parent ea8aeb1 commit 6f9b49a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions frontend/client/views/admin/Requests.vue
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,14 @@ export default {
try {
if (error.response.data.error.includes('Progress has been reset')) {
this.request.Progress = 0
} else {
this.$onError(error)
} else if (error.response.data.error.includes('Request has been deleted')) {
this.$notify({
title: 'Error',
message: 'This request contains invalid data, and has been deleted as a result',
type: 'error'
})
}
this.$onError(error)
} catch (e) {
this.$onError(error)
}
Expand Down
10 changes: 5 additions & 5 deletions request/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ func (r *PolicyRequest) Approve(hash string, unsealKey string) error {
unseals, err := unwrapUnseals(wrappingTokens)
if err != nil {
vault.WriteToCubbyhole("requests/"+hash, structs.Map(r))
return err
return errors.New("Progress has been reset: " + err.Error())
}

// generate root token
rootToken, err := generateRootToken(unseals)
if err != nil {
vault.WriteToCubbyhole("requests/"+hash, structs.Map(r))
return err
return errors.New("Progress has been reset: " + err.Error())
}
var rootAuth = &vault.AuthInfo{
Type: "token",
Expand All @@ -180,17 +180,17 @@ func (r *PolicyRequest) Approve(hash string, unsealKey string) error {
if r.Proposed == "" {
// if the request was to delete the policy
if err := rootAuth.DeletePolicy(r.PolicyName); err != nil {
return err
return errors.New(err.Error() + " Request has been deleted.")
}
r.Previous = ""
} else {
// if the request was to change the policy
if err := rootAuth.PutPolicy(r.PolicyName, r.Proposed); err != nil {
return err
return errors.New(err.Error() + " Request has been deleted.")
}
// update the request object with the new policy from vault
if p, err := rootAuth.GetPolicy(r.PolicyName); err != nil {
return err
return errors.New(err.Error() + " Request has been deleted.")
} else {
r.Previous = p
}
Expand Down

0 comments on commit 6f9b49a

Please sign in to comment.