Merge branch 'main' into fix/cascading-delete-on-login
This commit is contained in:
commit
d4fa6f6e4e
18
api/dns.go
18
api/dns.go
|
@ -2,6 +2,7 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -20,10 +21,23 @@ type FormError struct {
|
||||||
|
|
||||||
func userCanFuckWithDNSRecord(dbConn *sql.DB, user *database.User, record *database.DNSRecord) bool {
|
func userCanFuckWithDNSRecord(dbConn *sql.DB, user *database.User, record *database.DNSRecord) bool {
|
||||||
ownedByUser := (user.ID == record.UserID)
|
ownedByUser := (user.ID == record.UserID)
|
||||||
|
if !ownedByUser {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if !record.Internal {
|
if !record.Internal {
|
||||||
publicallyOwnedByUser := (record.Name == user.Username || strings.HasSuffix(record.Name, "."+user.Username))
|
userOwnedDomains := []string{
|
||||||
return ownedByUser && publicallyOwnedByUser
|
fmt.Sprintf("%s", user.Username),
|
||||||
|
fmt.Sprintf("%s.endpoints", user.Username),
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, domain := range userOwnedDomains {
|
||||||
|
isInSubDomain := strings.HasSuffix(record.Name, "."+domain)
|
||||||
|
if domain == record.Name || isInSubDomain {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
owner, err := database.FindFirstDomainOwnerId(dbConn, record.Name)
|
owner, err := database.FindFirstDomainOwnerId(dbConn, record.Name)
|
||||||
|
|
|
@ -55,11 +55,6 @@ func FindOrSaveUser(dbConn *sql.DB, user *User) (*User, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// _, err = dbConn.Exec(`UPDATE users SET mail = ?, username = ?, display_name = ? WHERE id = ?;`, user.Mail, user.Username, user.DisplayName, user.ID)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
return user, nil
|
return user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue