SPMod icon indicating copy to clipboard operation
SPMod copied to clipboard

[WIP] Access manager

Open Mistrick opened this issue 6 years ago • 3 comments

Description

Access manager

TODO:

  • [ ] Attach system to commands
  • [ ] Create interface?

Motivation and Context

How has this been tested?

#include <spmod>

public PluginInfo pluginInfo =
{
	name = "test",
	version = "0.0.0",
	author = "author",
	url = "https://github.com/Amaroq7/SPMod"
};

Group g;

public void OnPluginInit()
{
	g = Group("test");
	g.AttachPermission("one");
	g.AttachPermission("two");
	g.AttachPermission("three");

	Command("^say /p1$", TestP1);
	Command("^say /p2$", TestP2);
	Command("^say /p3$", TestP3);
	Command("^say /p4$", TestP4);
}

public PluginReturn TestP1(int client, Command cid)
{
	Player p = view_as<Player>(client);
	p.AttachGroup(g);
	p.AttachPermission("four");
}

public PluginReturn TestP2(int client, Command cid)
{
	Player p = view_as<Player>(client);
	PrintToServer("client %d, has one[%d], two[%d], three[%d], four[%d]",
					client,
					p.HasAccess("one"),
					p.HasAccess("two"),
					p.HasAccess("three"),
					p.HasAccess("four"))
}
public PluginReturn TestP3(int client, Command cid)
{
	Player p = view_as<Player>(client);
	p.RemovePermission("four");
}
public PluginReturn TestP4(int client, Command cid)
{
	Player p = view_as<Player>(client);
	p.RemoveGroup(g);
}

Screenshots (if appropriate):

image

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • [ ] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.

Mistrick avatar Aug 13 '18 19:08 Mistrick

I like the concept of groups and single permissions this gives us much more flexibility than flags.

I have a question, is there a possibility to exclude permissions for particular players? Let's say we have 2 players which belong to the same group f.e. admin and we want one of them to have all permissions from the group except f.e. ban.

Amaroq7 avatar Mar 25 '20 01:03 Amaroq7

I have a question, is there a possibility to exclude permissions for particular players? Let's say we have 2 players which belong to the same group f.e. admin and we want one of them to have all permissions from the group except f.e. ban.

Yes, I try to do system based on sets. We can add member for exceptions and after union in PlayerRole::hasAccess add complement with exceptions.

Mistrick avatar Mar 25 '20 06:03 Mistrick

SonarCloud Quality Gate failed.    Quality Gate failed

Bug E 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell C 163 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

sonarqubecloud[bot] avatar Oct 11 '23 17:10 sonarqubecloud[bot]