refactor: use Identifier.Equals() instead of bytes.Equal
This commit is contained in:
parent
180f125dcb
commit
e438c5d25e
5 changed files with 5 additions and 10 deletions
|
|
@ -22,7 +22,6 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
|
@ -63,7 +62,7 @@ func (uc *UserController) GetUser(c *gin.Context) {
|
|||
myuser := c.MustGet("LoggedUser").(*happydns.User)
|
||||
user := c.MustGet("user").(*happydns.User)
|
||||
|
||||
if bytes.Equal(user.Id, myuser.Id) {
|
||||
if user.Id.Equals(myuser.Id) {
|
||||
c.JSON(http.StatusOK, user)
|
||||
} else {
|
||||
c.JSON(http.StatusOK, &happydns.User{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"log"
|
||||
|
|
@ -74,7 +73,7 @@ func SameUserHandler(c *gin.Context) {
|
|||
myuser := c.MustGet("LoggedUser").(*happydns.User)
|
||||
user := c.MustGet("user").(*happydns.User)
|
||||
|
||||
if !bytes.Equal(user.Id, myuser.Id) {
|
||||
if !user.Id.Equals(myuser.Id) {
|
||||
log.Printf("%s: tries to do action as %s (logged %s)", c.ClientIP(), myuser.Id.String(), user.Id.String())
|
||||
c.AbortWithStatusJSON(http.StatusForbidden, happydns.ErrorResponse{Message: "Not authorized"})
|
||||
return
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
|
|
@ -52,7 +51,7 @@ func (s *KVStorage) ListDomains(u *happydns.User) (domains []*happydns.Domain, e
|
|||
return
|
||||
}
|
||||
|
||||
if bytes.Equal(z.Owner, u.Id) {
|
||||
if z.Owner.Equals(u.Id) {
|
||||
domains = append(domains, &z)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
|
|
@ -56,7 +55,7 @@ func (s *KVStorage) ListProviders(u *happydns.User) (srcs happydns.ProviderMessa
|
|||
|
||||
for iter.Next() {
|
||||
srcMsg := iter.Item()
|
||||
if !bytes.Equal(srcMsg.Owner, u.Id) {
|
||||
if !srcMsg.Owner.Equals(u.Id) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
package happydns
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -141,7 +140,7 @@ func (z *Zone) FindSubdomainService(subdomain Subdomain, id []byte) (int, *Servi
|
|||
|
||||
if services, ok := z.Services[subdomain]; ok {
|
||||
for k, svc := range services {
|
||||
if bytes.Equal(svc.Id, id) {
|
||||
if svc.Id.Equals(id) {
|
||||
return k, svc
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue