Skip to content

Bring user deletion account - #1893

Closed
tcitworld wants to merge 3 commits into
masterfrom
user-delete-account
Closed

tcitworld wants to merge 3 commits into
masterfrom
user-delete-account

Conversation

@tcitworld

@tcitworld tcitworld commented Oct 24, 2016 •

Copy link
Copy Markdown
Member

Bring the possibility for an user to delete it's own account. Administrators can enable/disable this functionality.

See owncloud/core#158

  • Security issues
  • Redirect to login with js after deleting account
  • Tests

@mention-bot

Copy link
Copy Markdown

@tcitworld, thanks for your PR! By analyzing the history of the files in this pull request, we identified @LukasReschke, @MorrisJobke and @icewind1991 to be potential reviewers.

Comment thread settings/Controller/UsersController.php Outdated
public function destroy($id) {
$userId = $this->userSession->getUser()->getUID();
$user = $this->userManager->get($id);
$userOwnDeletion = $this->config->getSystemValue('user_own_account_deletion', false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please no config.php switch. This should be stored in the database.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Okay. Where should it be activated by the administrator. Additional settings ?

Comment thread settings/js/personal.js Outdated
}
}

function deleteAccount () {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Global namespace 🙈 Yes I know, the other methods are also in the global namespace - but at some point we need to clean up this mess 😉

Comment thread settings/js/personal.js Outdated
}
}

function deleteAccount () {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Global namespace 🙈 Yes I know, the other methods are also in the global namespace - but at some point we need to clean up this mess 😉

@rullzer

rullzer commented Oct 24, 2016

Copy link
Copy Markdown
Member

Can't we just do this as an app?

@tcitworld

Copy link
Copy Markdown
Member Author

I thought it was a quite small feature to create an app. Also it's configurable by the admin.

@LukasReschke LukasReschke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd also prefer this to be in it's own app. But that may just be personal preference.

In any case, there are some problems with this:

  • Missing unit tests for the UsersController
  • The "delete your account" should only appear in the settings when it is possible (e.g. the user backend of the currently logged-in user supports it)
  • Some remarks that Morris had as well.

@tcitworld

Copy link
Copy Markdown
Member Author

Most of it is done. I just don't know where the admin setting should show up. Also, how to test if backend supports deletion (I've just put Database for now) ?

@tcitworld
tcitworld force-pushed the user-delete-account branch from f7392cf to 9a81ff8 Compare October 25, 2016 11:52
Comment thread settings/templates/personal.php Outdated
</div>
</div>

<?php if ($_['accountDeletionEnabled']) { ?>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be at the bottom of the site in my opinion

Comment thread settings/personal.php Outdated
}

// show account deletion button only if it's enabled and if the backend supports it
$accountDeletionEnabled = $config->getAppValue('core', 'user_own_account_deletion', false) && $user->getBackendClassName() === 'Database';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Most of it is done. I just don't know where the admin setting should show up. Also, how to test if backend supports deletion (I've just put Database for now) ?

\OCP\UserInterface::implementsActions + add an action constant + adjust the backends.

No hard-coded hackery here 😉

Comment thread lib/private/User/User.php
* @return bool
*/
public function canDeleteAccount() {
// TODO : Change this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For some reason. Any help here ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(bool)$this->config->getAppValue('core', 'user_own_account_deletion', 0) and store an integer would have been my approach.

Comment thread lib/public/IUser.php
/**
* check if the backend supports deleting user
*
* @return bool

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This or ownCloud notation ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm fine with this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We used 9.2 so far, I guess we should "unify" them all before the release and do one or the other.

Comment thread settings/personal.php

$formsAndMore = array_merge($formsAndMore, $formsMap);

if ($user->canDeleteAccount()) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Better way ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Signed-off-by: Thomas Citharel <[email protected]>
* Use OCP instead of OC js namespace
* Rewrite config entry condition
* Rebase

Signed-off-by: Thomas Citharel <[email protected]>
@tcitworld
tcitworld force-pushed the user-delete-account branch from e3aeb52 to a3902b5 Compare November 5, 2016 12:42
@tcitworld tcitworld added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Nov 5, 2016
@tcitworld

Copy link
Copy Markdown
Member Author

Rebased. Please review. :-)

@rullzer

rullzer commented Nov 5, 2016

Copy link
Copy Markdown
Member

I still really dislike this being in core. In 99.99% of the cases this is not required. For me the only real usecase is if a service provider wants to allow people to delete their accounts. Which is a fair use case. But, again, please do it as an app.

@MariusBluem

Copy link
Copy Markdown
Member

For me the only real usecase is if a service provider wants to allow people to delete their accounts. Which is a fair use case. But, again, please do it as an app.

Agreed. And Service Providers may want to use their own CRM to have better control over it. So the use-case is as small as this is something for a separate app, I think 😁 ...However: Good work 👍

@tcitworld tcitworld closed this Nov 5, 2016
@tcitworld

Copy link
Copy Markdown
Member Author

Okay ! (I will delete the branch later)

Comment thread lib/private/User/User.php
* @return bool
*/
public function canDeleteAccount() {
// TODO : Change this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no need for the bool casting here

@nickvergessen nickvergessen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs changes

public function destroy($id) {
$userId = $this->userSession->getUser()->getUID();
$user = $this->userManager->get($id);
$userOwnDeletion = $this->config->getAppValue('core', 'user_own_account_deletion', false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

default value should be 0

Comment thread settings/js/personal.js

OC.Settings.Personal = OC.Settings.Personal || {
deleteAccount: function() {
OC.dialogs.confirm('Do you really want to delete your account ? All your data will be lost !', 'Delete your account ?', function (res) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove the spaces before ? and !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants