Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature #19201: Add column "active" to users, to be able to activate or deactivate users #3550

Merged
merged 33 commits into from
Dec 8, 2023

Conversation

mohabmes
Copy link
Member

No description provided.

@Shnoulle
Copy link
Collaborator

My opinion : seems to be create event for only one plugin. Can be great if we can use for other purpose

@Shnoulle
Copy link
Collaborator

OK, i think it's a PR to add a core plugin for Cloud version.

But it's updating CE version for cloud version …
joomlaVerifyPassword included in CE.

Seems strange for me.

@olleharstedt
Copy link
Collaborator

OK, i think it's a PR to add a core plugin for Cloud version.

But it's updating CE version for cloud version … joomlaVerifyPassword included in CE.

Seems strange for me.

Yea, please wait, we'll clean this up. ^^

@olleharstedt olleharstedt changed the base branch from master to develop October 27, 2023 11:10
@olleharstedt olleharstedt changed the title CR-1343: Limit creation of new users New feature #19201: Add column "active" to users, to be able to activate or deactivate users Oct 27, 2023
@olleharstedt
Copy link
Collaborator

Modified the title of the PR.

@olleharstedt
Copy link
Collaborator

Next step would be to remove everything LS Cloud related from this PR and only keep functionality related to the new feature activate/deactivate user. :)

@olleharstedt
Copy link
Collaborator

olleharstedt commented Dec 1, 2023

Merged develop into this branch again and updated dbversion to 619.

App()->getPluginManager()->dispatchEvent($oEvent);
$data = $oEvent->get('data');

foreach ($data as $key => $item) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Usage of $event->append( for plugins

See https://manual.limesurvey.org/BeforeToolsMenuRender

$extraToolsMenuItems = $event->get('menuItems');

Warning : broke if data is null with php8.1. (remind to activate debug for fix and new feature).

@@ -498,6 +498,14 @@ public function getAdminFooter($url, $explanation, $return = false)
$aData['versiontitle'] = gT('Version');
}

$oEvent = new PluginEvent('beforeFooterRender');
Copy link
Collaborator

Choose a reason for hiding this comment

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

This event is perhaps not needed if you use asset manager to register a script with current_plan instead?

https://github.com/LimeSurvey/cloud_client_limesurvey/pull/24/files#r1415473939

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mohabmes Can you comment on why you marked this as resolved?

Copy link
Member Author

@mohabmes mohabmes Dec 6, 2023

Choose a reason for hiding this comment

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

@olleharstedt Registering a script with the current_plan at this point serves no purpose; we only wanted that event to transmit the current plan for the partial rendering of the appropriate plan upgrade modal, displaying the accurate next bigger plan. (no JS involved).

https://github.com/LimeSurvey/cloud_client_limesurvey/blob/cf8134b0814d93a98659e8f5ad9c54364a070ac4/dbversion-600/application/views/admin/super/footer.php#L239

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok. In that case, it's probably better if the beforeFooterRender spits out HTML instead of a data array, so that other plugins can insert whatever HTML they want without changing any LS core view files.

That also means that the view file planupgrade.php can be moved to the LS Pro plugin folder instead of the core view folder.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Compare with this event: https://manual.limesurvey.org/BeforeCloseHtml (only available in survey taking view, afaik; @Shnoulle you can confirm?).

So you can add a similar event to admin view called beforeCloseAdminHtml.

Copy link
Collaborator

Choose a reason for hiding this comment

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

beforeCloseHtml never work good … you can just use it for registering script.

Have a real way to add or update element is better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have a real way to add or update element is better.

Like menu classes or? Hard to see how that would work with something general.

Copy link
Collaborator

@Shnoulle Shnoulle Dec 6, 2023

Choose a reason for hiding this comment

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

Menu class : yes, it's interesting.

With public : we can replace or add .twig view, but need better too … with a way to really use twig block and extend

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems overkill for just adding some footer HTML, or?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems overkill for just adding some footer HTML, or?

I speak in general here :)

@@ -171,7 +178,7 @@ public function newUserSession()
$this->setAuthFailure(self::ERROR_USERNAME_INVALID);
return;
}
if ($user->isExpired()) {
if ($user->isExpired() || (isset($user->user_status) && !$user->user_status)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this check has to be moved to

application/core/LSUserIdentity.php
71 $authEvent = new PluginEvent('newUserSession', $this); // TODO: rename the plugin function authenticate()

Basically, never fire up the event "newUserSession" if username belongs to a non-active user.

Remember that the non-active check has to work for authentication plugins that are not in the git repository.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Must be moved to

public function getCurrentUserId()

Else you have same issue than : https://bugs.limesurvey.org/view.php?id=19117

PS : @olleharstedt #3607 still not reviewed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yeah, I did think about how to achieve that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But then we get the same issue with updates, or?

Copy link
Collaborator

Choose a reason for hiding this comment

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

But then we get the same issue with updates, or?

Yes, but need to be fixed on the same way :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@olleharstedt olleharstedt merged commit bb14772 into develop Dec 8, 2023
20 checks passed
@olleharstedt olleharstedt deleted the ls6/cr-1343/limit-creation-of-new-users branch December 8, 2023 08:53
@Shnoulle
Copy link
Collaborator

Shnoulle commented Dec 8, 2023

Someone need to report the issue with user keeping session when set as inactive !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants