Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Add limit in how many configurations each user may have. #47

Merged
merged 4 commits into from
Mar 20, 2020

Conversation

spetzreborn
Copy link
Contributor

@spetzreborn spetzreborn commented Mar 16, 2020

If the option max-number-client-config is more than 0 this number is the
maximum number of clients a user can create.

The setting only limits creation. If a user had created more
configurations before this setting is enforced or lowered the user may
user the service as before, just cant create any more configurations.

This partitionaly fixes #46 . I have tested the function that it works, but it does not notifies the user what the source of the problem is. I'm not familiar with node or svelte, but I have looked at:
https://github.com/keenethics/svelte-notifications
and that might be used as notification framework.
But I think this must be a discussion with the maintainers of their long time goal for the project.

Also the http status code I choose as an response might be discussed: 429.

Added 2020-03-19: This PR now includes an alert() when the user tried to create more than the limit.
Added 2020-03-20: Use http status 400 instead of 429 as discussed.

If the option max-number-client-config is more than 0 this number is the
maximum number of clients a user can create.

The setting only limits creation. If a user had created more
configurations before this setting is enforced or lowered the user may
user the service as before, just cant create any more configurations.
@spetzreborn
Copy link
Contributor Author

This PR works 'as is' but I think the question of notifying the user is a bigger issue.
There might be more functions that want/need to use an notification/error system.

Copy link
Contributor

@luna-duclos luna-duclos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one small nit

server.go Outdated Show resolved Hide resolved
When the user tries to create more configurations than are allow an
alert will pop up.
@spetzreborn
Copy link
Contributor Author

I have added an commit, #cea0434 in witch an alert() is raised when the user tries to create more configs then the limit.

It works, but perhaps not the best looking commit. I will happily take any suggestions or improvements.

server.go Outdated Show resolved Hide resolved
http 400 seems a better fit than 429 as a more generic error.
@freddd freddd merged commit fb5cf90 into EmbarkStudios:master Mar 20, 2020
@spetzreborn spetzreborn deleted the limit_client_configs branch March 20, 2020 15:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit number of configurations per users.
4 participants