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.
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)
srv.Serve(lis)
}

10
server/server.go

@ -16,11 +16,11 @@ import (
type usersServer struct {
proto.UsersServer
secret *string
secret string
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{})
return &usersServer{
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) {
// Make sure the secrets match.
if in.Secret != *m.secret {
if in.Secret != m.secret {
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) {
// Make sure the secrets match.
if in.Secret != *m.secret {
if in.Secret != m.secret {
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) {
// Make sure the secrets match.
if in.Secret != *m.secret {
if in.Secret != m.secret {
return nil, errors.New("Secrets do not match.")
}

Loading…
Cancel
Save