diff options
| author | Lizzy Hunt <lizzy.hunt@usu.edu> | 2024-03-29 16:35:04 -0600 |
|---|---|---|
| committer | Lizzy Hunt <lizzy.hunt@usu.edu> | 2024-03-29 16:35:04 -0600 |
| commit | 5080c566ac31ec622986c04f1812a1e88c88210e (patch) | |
| tree | d8dbaa766ef21b098c5740880facc2989c750295 /api/dns.go | |
| parent | 7cc13887eae7dd2a61900751e038d273313d077f (diff) | |
| download | hatecomputers.club-5080c566ac31ec622986c04f1812a1e88c88210e.tar.gz hatecomputers.club-5080c566ac31ec622986c04f1812a1e88c88210e.zip | |
guestbook!
Diffstat (limited to 'api/dns.go')
| -rw-r--r-- | api/dns.go | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -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 |
