|
|
@ -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.") |
|
|
|
} |
|
|
|
|
|
|
|