@Route(
"/password/reset",
name="apiv2_group_initialize_password"
)
@Method("POST")

@param Workspace $workspace

@return JsonResponse
427215
public function resetPasswordAction(Request $request)
    {
        $groups = $this->decodeIdsString($request, Group::class);
        $this->om->startFlushSuite();
        $i = 0;

        foreach ($groups as $group) {
            foreach ($group->getUsers() as $user) {
                $this->container->get('claroline.manager.user_manager')->sendResetPassword($user);
                ++$i;

                if (0 === $i % 200) {
                    $this->om->forceFlush();
                }
            }
        }

        $this->om->endFlushSuite();

        return new JsonResponse();
    }
644603
public function urlSubscriptionGenerateAction(Workspace $workspace)
    {
        $user = $this->tokenStorage->getToken()->getUser();

        if ( $user === 'anon.') {
            return $this->redirect(
                $this->generateUrl(
                    'claro_workspace_subscription_url_generate_anonymous',
                    array(
                        'workspace' => $workspace->getId(),
                        'toolName' => 'home'
                    )
                )
            );
        }

        $this->workspaceManager->addUserAction($workspace, $user);

        return $this->redirect(
            $this->generateUrl(
                'claro_workspace_open_tool', array('workspaceId' => $workspace->getId(), 'toolName' => 'home')
            )
        );
    }
1088768
public function resetAction(Request $request, PasswordResetToken $token): Response
    {
        $user = $this->userRepositoryCollection->findUserByToken($token);

        if ($user === null) {
            return new RedirectResponse(
                $this->router->generate('multi_user_login')
            );
        }

        $changePasswordTransferObject = ChangePasswordDataTransferObject::forUser($user);
        $form = $this->formFactory->create(ChangePasswordType::class, $changePasswordTransferObject);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->resetPasswordHandler->handle($form->getData());

            $this->flashBag->add(
                'success',
                $this->translator->trans(
                    'sumocoders.multiuserbundle.flash.password_reset_success'
                )
            );

            return new RedirectResponse(
                $this->router->generate('multi_user_login')
            );
        }

        return $this->templating->renderResponse(
            'SumoCodersFrameworkMultiUserBundle:PasswordReset:reset.html.twig',
            [
                'form' => $form->createView(),
            ]
        );
    }
627352
public function setBaseWorkspace(Workspace $workspace)
    {
        $userWorkspace = $this->userService->getPersonalWorkspace();
        $userWorkspace->setBaseWorkspace($workspace);
    }
652578
public function deleteWorkspace(Workspace $workspace)
    {
        $this->om->startFlushSuite();
        $root = $this->resourceManager->getWorkspaceRoot($workspace);
        $this->log('Removing root directory ' . $root->getName() . '[id:' . $root->getId() . ']');

        if ($root) {
            $children = $root->getChildren();
            $this->log('Looping through ' . count($children) . ' children...');

            if ($children) {
                foreach ($children as $node) {
                    $this->resourceManager->delete($node);
                }
            }
        }
        $this->dispatcher->dispatch(
            'claroline_workspaces_delete',
            'GenericDatas',
            array(array($workspace))
        );
        $this->om->remove($workspace);
        $this->om->endFlushSuite();
    }
658998
public function postReset(Request $request)
    {
        $this->validate($request, [
            'token'         => 'required',
            'email'         => 'required|email',
            'password'      => 'required|confirmed|min:6',
        ]);

        // Here we will attempt to reset the user's password. If it is successful we
        // will update the password on an actual user model and persist it to the
        // database. Otherwise we will parse the error and return the response.
        $response = $this->broker()->reset(
            $this->credentials($request), function ($user, $password) {
                $this->resetPassword($user, $password);
            }
        );

        switch ($response) {
            case Password::PASSWORD_RESET:
                return $this->getResetSuccessResponse('pulsar::passwords.reset');

            default:
                return $this->getResetFailureResponse($request, $response);
        }
    }
620944
public function resetPassword(array $data)
    {
        $result = array();
        $this->hook->attach('user.reset.password.before', $data, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        if (empty($data['user']['user_id'])) {
            return $this->getResultError();
        }

        if (isset($data['password'])) {
            $result = $this->resetPasswordFinish($data);
        } else {
            $result = $this->resetPasswordStart($data);
        }

        $this->session->regenerate(true);
        $this->hook->attach('user.reset.password.after', $data, $result, $this);
        return (array) $result;
    }
895295
public function updateAction(Workspace $workspace)
    {
        if ($workspace->getTitle() === '') {
            $workspace->setTitle($workspace->getName());
        }

        $this->workspaceRepository->update($workspace);
        $this->addFlashMessage($this->translator->translateById('workspaces.workspaceHasBeenUpdated', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos'));
        $this->redirect('index');
    }
205750
public function registerAndRedirect(Workspace $workspace, Request $request)
    {
        $user = $this->tokenStorage->getToken()->getUser();

        if ($workspace->getSelfRegistration()) {
            if ($workspace->getRegistrationValidation()) {
                $this->workspaceManager->addUserQueue($workspace, $user);
            } else {
                $this->workspaceManager->addUserAction($workspace, $user);
            }

            return $this->openAction($workspace->getId(), $request);
        } else {
            throw new \Exception('No self registration allowed');
        }
    }
1364295
public function workspaceHomeTabDeleteAction(
        Workspace $workspace,
        HomeTab $homeTab
    )
    {
        $this->checkWorkspaceEditionAccess($workspace);
        $this->checkWorkspaceAccessForHomeTab($homeTab, $workspace);
        $this->homeTabManager->deleteHomeTab($homeTab);

        return new Response('success', 204);
    }
72593
public function userSearchInWorkspaceAction($workspaceId, $search)
    {
        $workspace = $this->workspaceManager->getWorkspaceById($workspaceId);
        $users = $this->userManager->getAllUsersByWorkspaceAndName($workspace, $search, 1, 10);
        $usersArray = $this->userManager->toArrayForPicker($users);

        return new JsonResponse($usersArray);
    }
160966
public function workspaceEditFormAction(Workspace $workspace)
    {
        $user = $this->tokenStorage->getToken()->getUser();
        $this->checkAccess($workspace);
        $username = is_null($workspace->getCreator()) ? '' : $workspace->getCreator()->getUsername();
        $creationDate = is_null($workspace->getCreationDate()) ? null : $this->utilities->intlDateFormat(
            $workspace->getCreationDate()
        );
        $expDate = is_null($workspace->getEndDate()) ? null : $this->utilities->intlDateFormat(
            $workspace->getEndDate()
        );
        $count = $this->workspaceManager->countUsers($workspace, true);
        $storageUsed = $this->workspaceManager->getUsedStorage($workspace);
        $storageUsed = $this->utilities->formatFileSize($storageUsed);
        $countResources = $this->workspaceManager->countResources($workspace);
        $workspaceAdminTool = $this->toolManager->getAdminToolByName('workspace_management');
        $isAdmin = $this->authorization->isGranted('OPEN', $workspaceAdminTool);

        $form = $this->formFactory->create(
            FormFactory::TYPE_WORKSPACE_EDIT,
            array(
                $username,
                $creationDate,
                $count,
                $storageUsed,
                $countResources,
                $isAdmin,
                $expDate
            ),
            $workspace
        );

        if ($workspace->getSelfRegistration()) {
            $url = $this->router->generate(
                'claro_workspace_subscription_url_generate',
                array('workspace' => $workspace->getId()),
                true
            );
        } else {
            $url = '';
        }

        return array(
            'form' => $form->createView(),
            'workspace' => $workspace,
            'url' => $url,
            'user' => $user,
            'count' => $count
        );
    }
861900
public function resetPassword()
    {
        $user = $this->_user;
        $user->password = $this->password;
        $user->removePasswordResetToken();

        return $user->save();
    }
1314671
public function reset(string $key) : Response
    {
        //is the key empty or does it existe?
        if (empty($key) || !$userData = Users::findFirst(['user_activation_forgot = :key:', 'bind' => ['key' => $key]])) {
            throw new Exception(_('This Key to reset password doesn\'t exist'));
        }

        // Get the new password and the verify
        $newPassword = trim($this->request->getPost('new_password', 'string'));
        $verifyPassword = trim($this->request->getPost('verify_password', 'string'));

        //Ok let validate user password
        $validation = new Validation();
        $validation->add('new_password', new PresenceOf(['message' => _('The password is required.')]));
        $validation->add('new_password', new StringLength(['min' => 8, 'messageMinimum' => _('Password is too short. Minimum 8 characters.')]));

        $validation->add('new_password', new Confirmation([
            'message' => _('Passwords do not match.'),
            'with' => 'verify_password',
        ]));

        //validate this form for password
        $messages = $validation->validate($this->request->getPost());
        if (count($messages)) {
            foreach ($messages as $message) {
                throw new Exception($message);
            }
        }

        // Check that they are the same
        if ($newPassword == $verifyPassword) {
            // Has the password and set it
            $userData->user_activation_forgot = '';
            $userData->user_active = 1;
            $userData->password = Users::passwordHash($newPassword);

            // Update
            if ($userData->update()) {
                //log the user out of the site from all devices
                $session = new Sessions();
                $session->end($userData);

                $this->sendEmail($userData, 'reset');

                return $this->response(_('Congratulations! You\'ve successfully changed your password.'));
            } else {
                throw new Exception(current($userData->getMessages()));
            }
        } else {
            throw new Exception(_('Password are not the same'));
        }
    }
16421
public function rename(Workspace $workspace, $name)
    {
        $workspace->setName($name);
        $root = $this->resourceManager->getWorkspaceRoot($workspace);
        $root->setName($name);
        $this->om->persist($workspace);
        $this->om->persist($root);
        $this->om->flush();
    }
915693
public function changeWorkspace($workspaceName)
    {
        $this->init();
        $this->session->logout();
        $this->profile->set('phpcr', 'workspace', $workspaceName);
        $this->initSession($this->profile);
    }
535932
private function getRegistration(Workspace $workspace, array $options)
    {
        if ($workspace->getDefaultRole()) {
            if (in_array(Options::REFRESH_UUID, $options)) {
                $defaultRole = [
                  'translationKey' => $workspace->getDefaultRole()->getTranslationKey(),
                  'type' => $workspace->getDefaultRole()->getType(),
                ];
            } else {
                $defaultRole = [
                    'id' => $workspace->getDefaultRole()->getUuid(),
                    'name' => $workspace->getDefaultRole()->getName(),
                    'type' => $workspace->getDefaultRole()->getType(), // TODO : should be a string for better data readability
                    'translationKey' => $workspace->getDefaultRole()->getTranslationKey(),
                ];
            }
        } else {
            $defaultRole = null;
        }

        return [
            'validation' => $workspace->getRegistrationValidation(),
            'waitingForRegistration' => $workspace->getSelfRegistration() ? $this->waitingForRegistration($workspace) : false,
            'selfRegistration' => $workspace->getSelfRegistration(),
            'selfUnregistration' => $workspace->getSelfUnregistration(),
            'defaultRole' => $defaultRole,
        ];
    }