Browse Source

Fix pointer references

master
parent
commit
3fd5b1641e
Signed by: chris GPG Key ID: 3025DCBD46F81C0F
  1. 2
      cmd/server/main.go
  2. 10
      server/server.go

2
cmd/server/main.go

@ -71,7 +71,7 @@ func main() {
// Start listening for requests. // Start listening for requests.
srv := grpc.NewServer() srv := grpc.NewServer()
proto.RegisterUsersServer(srv, server.NewUsersServer(&config.Secret, db))
proto.RegisterUsersServer(srv, server.NewUsersServer(config.Secret, db))
log.Printf("Listening on :%d", config.Port) log.Printf("Listening on :%d", config.Port)
srv.Serve(lis) srv.Serve(lis)
} }

10
server/server.go

@ -16,11 +16,11 @@ import (
type usersServer struct { type usersServer struct {
proto.UsersServer proto.UsersServer
secret *string
secret string
db *gorm.DB db *gorm.DB
} }
func NewUsersServer(secret *string, db *gorm.DB) proto.UsersServer {
func NewUsersServer(secret string, db *gorm.DB) proto.UsersServer {
db.AutoMigrate(&models.User{}, &models.Role{}, &models.Session{}, &models.PasswordToken{}) db.AutoMigrate(&models.User{}, &models.Role{}, &models.Session{}, &models.PasswordToken{})
return &usersServer{ return &usersServer{
secret: secret, secret: secret,
@ -124,7 +124,7 @@ func (m *usersServer) Logout(ctx context.Context, in *proto.LogoutRequest) (*pro
func (m *usersServer) Authorize(ctx context.Context, in *proto.AuthorizeRequest) (*proto.AuthorizeResponse, error) { func (m *usersServer) Authorize(ctx context.Context, in *proto.AuthorizeRequest) (*proto.AuthorizeResponse, error) {
// Make sure the secrets match. // Make sure the secrets match.
if in.Secret != *m.secret {
if in.Secret != m.secret {
return nil, errors.New("Secrets do not match.") return nil, errors.New("Secrets do not match.")
} }
@ -233,7 +233,7 @@ func (m *usersServer) ChangePassword(ctx context.Context, in *proto.ChangePasswo
func (m *usersServer) ListRoles(ctx context.Context, in *proto.ListRolesRequest) (*proto.ListRolesResponse, error) { func (m *usersServer) ListRoles(ctx context.Context, in *proto.ListRolesRequest) (*proto.ListRolesResponse, error) {
// Make sure the secrets match. // Make sure the secrets match.
if in.Secret != *m.secret {
if in.Secret != m.secret {
return nil, errors.New("Secrets do not match.") return nil, errors.New("Secrets do not match.")
} }
@ -256,7 +256,7 @@ func (m *usersServer) ListRoles(ctx context.Context, in *proto.ListRolesRequest)
func (m *usersServer) SetRoles(ctx context.Context, in *proto.SetRolesRequest) (*proto.SetRolesResponse, error) { func (m *usersServer) SetRoles(ctx context.Context, in *proto.SetRolesRequest) (*proto.SetRolesResponse, error) {
// Make sure the secrets match. // Make sure the secrets match.
if in.Secret != *m.secret {
if in.Secret != m.secret {
return nil, errors.New("Secrets do not match.") return nil, errors.New("Secrets do not match.")
} }

Loading…
Cancel
Save