mirror of
https://github.com/cloudflare/redoctober.git
synced 2026-01-08 15:21:50 +00:00
Merge pull request #15 from cloudflare/alberts/issue14
Tweak error returns to work with older Go. Fixes #14
This commit is contained in:
@@ -330,21 +330,21 @@ func WriteRecordsToDisk() error {
|
||||
return errors.New("Path not initialized")
|
||||
}
|
||||
|
||||
if jsonDiskRecord, err := json.Marshal(records); err == nil {
|
||||
return ioutil.WriteFile(localPath, jsonDiskRecord, 0644)
|
||||
} else {
|
||||
jsonDiskRecord, err := json.Marshal(records)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(localPath, jsonDiskRecord, 0644)
|
||||
}
|
||||
|
||||
// AddNewRecord adds a new record for a given username and password.
|
||||
func AddNewRecord(name, password string, admin bool) (PasswordRecord, error) {
|
||||
if pr, err := createPasswordRec(password, admin); err == nil {
|
||||
SetRecord(pr, name)
|
||||
return pr, WriteRecordsToDisk()
|
||||
} else {
|
||||
pr, err := createPasswordRec(password, admin)
|
||||
if err != nil {
|
||||
return pr, err
|
||||
}
|
||||
SetRecord(pr, name)
|
||||
return pr, WriteRecordsToDisk()
|
||||
}
|
||||
|
||||
// ChangePassword changes the password for a given user.
|
||||
|
||||
@@ -201,9 +201,8 @@ func main() {
|
||||
}()
|
||||
|
||||
s, l, err := NewServer(process, *staticPath, *addr, *certPath, *keyPath, *caPath)
|
||||
if err == nil {
|
||||
s.Serve(*l)
|
||||
} else {
|
||||
if err != nil {
|
||||
log.Fatalf("Error starting redoctober server: %s\n", err)
|
||||
}
|
||||
s.Serve(*l)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user