public function resetAction(Request $request)
	{
		// TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} "
		if (!$request->request->has('user_id')) {
			throw new CmsException(null, 'User id is not set');
		}

		$userId = $request->request->get('user_id');

		$user = $this->container->getDoctrine()->getRepository('CmsAuthentication:User')->findOneById($userId);

		if (empty($user)) {
			throw new CmsException(null, 'Can\'t find user with such id');
		}

		$password = substr(md5(rand() . time()), 0, 8);

		$user->setPassword($this->encodePassword($user, $password));
		$this->container->getDoctrine()->getManager()->flush();

		$message = \Swift_Message::newInstance(
			'SiteSupra password reset',
			sprintf('Hi %s, your new password is: %s', $user->getLogin(), $password)
		);

		$message->setTo($user->getEmail());
		$message->setFrom($this->container->getParameter('framework.swiftmailer.default_from'));

		$this->container->getMailer()->send($message);

//		$this->checkActionPermission($user->getGroup(), Group::PERMISSION_MODIFY_USER_NAME);

		return new SupraJsonResponse(null);
	}
public function resetAction(Request $request)
	{
		// TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} "
		if (!$request->request->has('user_id')) {
			throw new CmsException(null, 'User id is not set');
		}

		$userId = $request->request->get('user_id');

		$user = $this->container->getDoctrine()->getRepository('CmsAuthentication:User')->findOneById($userId);

		if (empty($user)) {
			throw new CmsException(null, 'Can\'t find user with such id');
		}

		$password = substr(md5(rand() . time()), 0, 8);

		$user->setPassword($this->encodePassword($user, $password));
		$this->container->getDoctrine()->getManager()->flush();

		$message = \Swift_Message::newInstance(
			'SiteSupra password reset',
			sprintf('Hi %s, your new password is: %s', $user->getLogin(), $password)
		);

		$message->setTo($user->getEmail());
		$message->setFrom($this->container->getParameter('framework.swiftmailer.default_from'));

		$this->container->getMailer()->send($message);

//		$this->checkActionPermission($user->getGroup(), Group::PERMISSION_MODIFY_USER_NAME);

		return new SupraJsonResponse(null);
	}
public function resetAction ( Request $ request ) { // TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} " if ( ! $ request -> request -> has ( 'user_id' ) ) { throw new CmsException ( null , 'User id is not set' ) ; } $ userId = $ request -> request -> get ( 'user_id' ) ; $ user = $ this -> container -> getDoctrine ( ) -> getRepository ( 'CmsAuthentication:User' ) -> findOneById ( $ userId ) ; if ( empty ( $ user ) ) { throw new CmsException ( null , 'Can\'t find user with such id' ) ; } $ password = substr ( md5 ( rand ( ) . time ( ) ) , 0 , 8 ) ; $ user -> setPassword ( $ this -> encodePassword ( $ user , $ password ) ) ; $ this -> container -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; $ message = \ Swift_Message :: newInstance ( 'SiteSupra password reset' , sprintf ( 'Hi %s, your new password is: %s' , $ user -> getLogin ( ) , $ password ) ) ; $ message -> setTo ( $ user -> getEmail ( ) ) ; $ message -> setFrom ( $ this -> container -> getParameter ( 'framework.swiftmailer.default_from' ) ) ; $ this -> container -> getMailer ( ) -> send ( $ message ) ; //		$this->checkActionPermission($user->getGroup(), Group::PERMISSION_MODIFY_USER_NAME); return new SupraJsonResponse ( null ) ; }
Password reset action
Password reset action