Skip to content

Conversation

@blizzz
Copy link
Member

@blizzz blizzz commented Jun 14, 2019

This PR adds following two switches for creating new users:

  • requiring email address
  • auto-generation of userid

The motivation is to allow untechnical (sub)admins to allow to create users on an external backend. The user id does not play a role, but the email has to be enforced.

Therefore, there are no graphical switches. Bu the flags can be set via occ and they also do work with the local backend. For testing:

occ config:app:set settings newUser.requireEmail --value=yes

This flag sets the email field to required when creating a new user. The provsioning API errors with 110 if it is not provided.

occ config:app:set settings newUser.generateUserID --value=yes

This disables the new username field on the users page. The user will be appended to the list after creation with a random 10-character long ascii string. In case an unexisting userid could not be generated, the provisioning API will error with 111 after 10 attempts.

$isAdmin = $this->groupManager->isAdmin($user->getUID());
$subAdminManager = $this->groupManager->getSubAdmin();

if(empty($userid) && (bool)$this->config->getAppValue('settings', 'newUser.generateUserID', false)) {
Copy link
Member

Choose a reason for hiding this comment

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

Casting? Shouldn't we rather check against the exact value? '1'?
Or is it not a bad practice :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh … yeah, whyever I was doing it this way. I guess I was carried away by my urge to have boolean meaning be treated boolean. Even the cast useless here. I'll change it :)

Copy link
Member

Choose a reason for hiding this comment

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

@blizzz well, you're the php expert here ;)
So if you say it's fine, it's fine for me! 🚀

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

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

Code and tests are good. A small nitpick that is maybe not an issue! :)

@blizzz blizzz force-pushed the enh/noid/user-creation-options branch 2 times, most recently from 5c7163a to a0695ed Compare June 18, 2019 23:36
@blizzz
Copy link
Member Author

blizzz commented Jun 19, 2019

May I have a second reviewer, please?

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

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

Do I count? 😄

@wiswedel
Copy link
Contributor

@juliushaertl @georgehrke @schiessle @vincchan
Can someone please review this PR? We have to deliver.
Thx

@blizzz
Copy link
Member Author

blizzz commented Jun 19, 2019

Meh, conflicts … who dared to merge other stuff first 😝 OK, gonna rebase.

Do I count? smile

If this is one of your other personalities speaking, then, I think, yes, why not? 🙃 🤡

blizzz added 3 commits June 19, 2019 17:02
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz blizzz force-pushed the enh/noid/user-creation-options branch from a0695ed to faeb4a6 Compare June 19, 2019 15:16
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz blizzz force-pushed the enh/noid/user-creation-options branch from faeb4a6 to 05b3288 Compare June 20, 2019 00:10
@blizzz blizzz requested a review from nickvergessen June 20, 2019 15:00
Copy link
Member

@georgehrke georgehrke left a comment

Choose a reason for hiding this comment

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

Tiny nitpick, otherwise good to go 👍

$isAdmin = $this->groupManager->isAdmin($user->getUID());
$subAdminManager = $this->groupManager->getSubAdmin();

if(empty($userid) && $this->config->getAppValue('settings', 'newUser.generateUserID', '0') === '1') {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: we usually use 'yes' and 'no' (see the enabled configkey for example)

Copy link
Member

Choose a reason for hiding this comment

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

we also don't use getAppValue('settings' anywhere, it's usually getAppValue('core'

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed! Ok, will adjust, thank you!

$generatePasswordResetToken = true;
}

if ($email === '' && $this->config->getAppValue('settings', 'newUser.requireEmail', '0') === '1') {
Copy link
Member

Choose a reason for hiding this comment

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

see above

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz blizzz force-pushed the enh/noid/user-creation-options branch from 762876b to 29449f8 Compare June 21, 2019 08:22
@blizzz blizzz merged commit c1eff72 into master Jun 21, 2019
@blizzz blizzz deleted the enh/noid/user-creation-options branch June 21, 2019 09:09
}

return new DataResponse();
return new DataResponse(['UserID' => $userid]);
Copy link
Member

Choose a reason for hiding this comment

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

should we use id, so the key is the same as from getUserData?

Copy link
Member

Choose a reason for hiding this comment

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

AH yes maybe we should!
@blizzz ?

Copy link
Member Author

Choose a reason for hiding this comment

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

makes sense

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

6 participants