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

[stable10] compare UIDs instead of objects when changing email address #32391

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion settings/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ public function changeMail($token, $userId) {
$user = $this->userManager->get($userId);
$sessionUser = $this->userSession->getUser();

if ($user !== $sessionUser) {
if ($user->getUID() !== $sessionUser->getUID()) {
$this->log->error("The logged in user is different than expected.", ['app' => 'settings']);
return new RedirectResponse($this->urlGenerator->linkToRoute('settings.SettingsPage.getPersonal', ['changestatus' => 'error']));
}
Expand Down
17 changes: 14 additions & 3 deletions tests/Settings/Controller/UsersControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2306,14 +2306,25 @@ public function testSetDisplayNameFails() {
public function testDifferentLoggedUserAndRequestUser() {
$token = 'AVerySecretToken';
$userId = 'ExistingUser';
$differentUserId = 'ExistingUser2';
$mailAddress = 'sample@email.com';
$userObject = $this->getMockBuilder('OCP\IUser')
$userObject = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()->getMock();
$diffUserObject = $this->getMockBuilder('OCP\IUser')
$userObject
->expects($this->atLeastOnce())
->method('getUID')
->willReturn($userId);

$diffUserObject = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()->getMock();

$diffUserObject
->expects($this->atLeastOnce())
->method('getUID')
->willReturn($differentUserId);

$this->container['UserManager']
->expects($this->once())
->expects($this->atLeastOnce())
->method('get')
->with($userId)
->will($this->returnValue($userObject));
Expand Down