Skip to content

feat: User management with admin user - #11

Merged
lvarin merged 13 commits into
devfrom
admin-user
Apr 11, 2022
Merged

lvarin merged 13 commits into
devfrom
admin-user

Conversation

@akash2237778

Copy link
Copy Markdown
Collaborator

Added user management with user verification by admin users.

config.yaml contains a list of admin users who have the privilege to verify administrator user accounts. Also, administrators can use /users/register to create a new account (by default unverified).

@akash2237778
akash2237778 requested review from lvarin and uniqueg March 1, 2022 18:04
@lvarin

lvarin commented Mar 3, 2022

Copy link
Copy Markdown
Collaborator

As a general rule, I do not like when a single PR contains independent changes. Like in this case, a new feature is bundled together with format changes like changing single quotes to double quotes.

Do not change that in this PR, as it will make more confusing.

@lvarin lvarin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Most requested changes are not so important. Mostly coding style. We do not have a way to test this properly without Pubgrade being deployed in The Chzek or Greek cluster.

The biggest complain I have is that all the single quotes to double quotes, the separate the parameters in lines, ... Must have been done in another PR. It is not nce for the reviewers to scroll through thousand of irrelevant changes to find the relevant change. If this PR was split in two, the review would have taken much much less time.

It looks good overall.

Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread tests/pubgrade/test_server.py Resolved
Comment thread tests/pubgrade/test_server.py Resolved
Comment thread tests/pubgrade/test_server.py Resolved
Comment thread tests/pubgrade/test_server.py Resolved
Comment thread tests/pubgrade/endpoints/test_builds.py Resolved
@lvarin

lvarin commented Mar 11, 2022

Copy link
Copy Markdown
Collaborator

Why did you squash the commits into one? That makes it harder to follow the changes. You better squash the commits after the review is done.

@akash2237778

Copy link
Copy Markdown
Collaborator Author

Ok I'll take care now, won't squash new commits.

@akash2237778

Copy link
Copy Markdown
Collaborator Author

Yes, for now, admin can't delete any user. Do I implement that as well, won't take much time if needed?

* Added more customizable PVCs

* Configurable PV size
@lvarin

lvarin commented Mar 14, 2022

Copy link
Copy Markdown
Collaborator

Yes, for now, admin can't delete any user. Do I implement that as well, won't take much time if needed?

That would be useful foe the admins, initially mostly for testing. If it is simple, please do :)

@akash2237778

Copy link
Copy Markdown
Collaborator Author

Yes, for now, admin can't delete any user. Do I implement that as well, won't take much time if needed?

That would be useful foe the admins, initially mostly for testing. If it is simple, please do :)

Sure

Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
@akash2237778

Copy link
Copy Markdown
Collaborator Author

@lvarin I've fixed all the requested changes. Can you please re-review?

@lvarin

lvarin commented Mar 28, 2022

Copy link
Copy Markdown
Collaborator

I see you are still doing minor format changes in each commit. I would rather prefer this changes are doing in a separate PR, after we approve this one.

Also I saw few of your comments, and they are descriptions of the code (which is useless), but not explanation of what do you want to accomplish.

     try:
         id_charset = eval(id_charset)
     except Exception:
         id_charset = "".join(sorted(set(id_charset)))

Instead of saying "Try to evaluate python expression and if any exception occurs, use set to create charset." (which is just reading the code), you should help to understand to the person who will read this in the future. Answer questions like:

Why the first eval can fail and not the second? What are some valid values of id_charset? What is the variable configuring?

I can see that set removes duplicates, sorted sorts them alphabetically and join makes a string out of it, but WHY?

@lvarin lvarin mentioned this pull request Mar 31, 2022
@akash2237778
akash2237778 requested a review from lvarin April 5, 2022 03:23
Comment thread pubgrade/modules/endpoints/users.py Outdated
user_object = {}

try:
user_object["name"] = data["name"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

StackOverflow gave me something like:

''.join(e for e in string if e.isalnum() or e.isspace())

It is simple, but already cleans up the input

Comment thread pubgrade/modules/endpoints/users.py Outdated
Sanitised text

"""
return re.sub('[\W_]+', '', text) No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Almost there but now:

>>> string='Al;varo Gonzalez'
>>> re.sub('[\W_]+', '', string) 
'AlvaroGonzalez'

Spaces are also deleted.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Works for me:

>>> string='Alvaro;     Go/;][-=nzalez'
>>> ''.join(e for e in string if e.isalnum() or e.isspace())
'Alvaro   \tGonzalez'

spaces are not deleted

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes it's working, by mistake I tried with old function.

@lvarin lvarin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@lvarin

lvarin commented Apr 5, 2022

Copy link
Copy Markdown
Collaborator

@uniqueg Do you want to review this as well?

For me it looks fine and ready to merge

@lvarin
lvarin merged commit 3817f12 into dev Apr 11, 2022
@lvarin
lvarin deleted the admin-user branch April 11, 2022 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants