summaryrefslogtreecommitdiff
path: root/api/dns.go
diff options
context:
space:
mode:
authorLizzy Hunt <lizzy.hunt@usu.edu>2024-03-29 16:35:04 -0600
committerLizzy Hunt <lizzy.hunt@usu.edu>2024-03-29 16:35:04 -0600
commit5080c566ac31ec622986c04f1812a1e88c88210e (patch)
treed8dbaa766ef21b098c5740880facc2989c750295 /api/dns.go
parent7cc13887eae7dd2a61900751e038d273313d077f (diff)
downloadhatecomputers.club-5080c566ac31ec622986c04f1812a1e88c88210e.tar.gz
hatecomputers.club-5080c566ac31ec622986c04f1812a1e88c88210e.zip
guestbook!
Diffstat (limited to 'api/dns.go')
-rw-r--r--api/dns.go22
1 files changed, 10 insertions, 12 deletions
diff --git a/api/dns.go b/api/dns.go
index 0205f5d..a1739d3 100644
--- a/api/dns.go
+++ b/api/dns.go
@@ -72,25 +72,24 @@ func CreateDNSRecordContinuation(context *RequestContext, req *http.Request, res
formErrors.Errors = append(formErrors.Errors, "invalid ttl")
}
- dnsRecord := &database.DNSRecord{
- UserID: context.User.ID,
- Name: name,
- Type: recordType,
- Content: recordContent,
- TTL: ttlNum,
- Internal: internal,
- }
-
- dnsRecords, err := database.GetUserDNSRecords(context.DBConn, context.User.ID)
+ dnsRecordCount, err := database.CountUserDNSRecords(context.DBConn, context.User.ID)
if err != nil {
log.Println(err)
resp.WriteHeader(http.StatusInternalServerError)
return failure(context, req, resp)
}
- if len(dnsRecords) >= MAX_USER_RECORDS {
+ if dnsRecordCount >= MAX_USER_RECORDS {
formErrors.Errors = append(formErrors.Errors, "max records reached")
}
+ dnsRecord := &database.DNSRecord{
+ UserID: context.User.ID,
+ Name: name,
+ Type: recordType,
+ Content: recordContent,
+ TTL: ttlNum,
+ Internal: internal,
+ }
if !userCanFuckWithDNSRecord(context.DBConn, context.User, dnsRecord) {
formErrors.Errors = append(formErrors.Errors, "'name' must end with "+context.User.Username+" or you must be a domain owner for internal domains")
}
@@ -122,7 +121,6 @@ func CreateDNSRecordContinuation(context *RequestContext, req *http.Request, res
return success(context, req, resp)
}
- (*context.TemplateData)["DNSRecords"] = dnsRecords
(*context.TemplateData)["FormError"] = &formErrors
(*context.TemplateData)["RecordForm"] = dnsRecord