admin: Save challenge info over importer
This commit is contained in:
parent
aab66bf612
commit
58217d1d8a
@ -1,6 +1,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -82,7 +83,14 @@ func saveChallengeInfo(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := settings.SaveChallengeInfo(path.Join(settings.SettingsDir, settings.ChallengeFile), info); err != nil {
|
jenc, err := json.Marshal(info)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = sync.WriteFileContent(sync.GlobalImporter, "challenge.json", jenc)
|
||||||
|
if err != nil {
|
||||||
log.Println("Unable to SaveChallengeInfo:", err.Error())
|
log.Println("Unable to SaveChallengeInfo:", err.Error())
|
||||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to save challenge info: %s", err.Error())})
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to save challenge info: %s", err.Error())})
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user