public function resolveAction()
    {
        $success    = null;
        $failed     = null;
        $service    = $this->getServiceLocator();
        $userModel  = $service->get( 'Grid\User\Model\User\Model' );
        $confirm    = $service->get( 'Grid\User\Model\ConfirmHash' );
        $hash       = $this->params()
                           ->fromRoute( 'hash' );

        if ( $confirm->has( $hash ) &&
             ( $email = $confirm->find( $hash ) ) )
        {
            $user = $userModel->findByEmail( $email );

            if ( ! empty( $user ) &&
                 $user->state != UserStructure::STATE_BANNED )
            {
                $request    = $this->getRequest();
                $data       = $request->getPost();
                $form       = $service->get( 'Form' )
                                      ->get( 'Grid\User\PasswordChangeRequest\Resolve' );

                if ( $request->isPost() )
                {
                    $form->setData( $data );

                    if ( $form->isValid() )
                    {
                        $data = $form->getData();
                        $user->state        = UserStructure::STATE_ACTIVE;
                        $user->confirmed    = true;
                        $user->password     = $data['password'];

                        if ( $user->save() )
                        {
                            $confirm->delete( $hash );
                            $success = true;
                        }
                    }
                    else
                    {
                        $success = false;
                    }
                }
            }
            else
            {
                $failed = true;
            }
        }
        else
        {
            $failed = true;
        }

        if ( $failed === true )
        {
            $this->messenger()
                 ->add( 'user.form.passwordChange.failed',
                        'user', Message::LEVEL_ERROR );

            return $this->redirect()
                        ->toRoute( 'Grid\User\PasswordChangeRequest\Create', array(
                            'locale'    => (string) $this->locale(),
                            'returnUri' => '/',
                        ) );
        }

        if ( $success === true )
        {
            $this->messenger()
                 ->add( 'user.form.passwordChange.success',
                        'user', Message::LEVEL_INFO );

            return $this->redirect()
                        ->toRoute( 'Grid\User\Authentication\Login', array(
                            'locale'    => (string) $this->locale(),
                            'returnUri' => '/',
                        ) );
        }

        if ( $success === false )
        {
            $this->messenger()
                 ->add( 'user.form.passwordChange.resolve.failed',
                        'user', Message::LEVEL_ERROR );
        }

        $this->paragraphLayout();

        return new MetaContent( 'user.passwordChangeRequest', array(
            'success'   => $success,
            'form'      => $form,
        ) );
    }
public function resolveAction()
    {
        $success    = null;
        $failed     = null;
        $service    = $this->getServiceLocator();
        $userModel  = $service->get( 'Grid\User\Model\User\Model' );
        $confirm    = $service->get( 'Grid\User\Model\ConfirmHash' );
        $hash       = $this->params()
                           ->fromRoute( 'hash' );

        if ( $confirm->has( $hash ) &&
             ( $email = $confirm->find( $hash ) ) )
        {
            $user = $userModel->findByEmail( $email );

            if ( ! empty( $user ) &&
                 $user->state != UserStructure::STATE_BANNED )
            {
                $request    = $this->getRequest();
                $data       = $request->getPost();
                $form       = $service->get( 'Form' )
                                      ->get( 'Grid\User\PasswordChangeRequest\Resolve' );

                if ( $request->isPost() )
                {
                    $form->setData( $data );

                    if ( $form->isValid() )
                    {
                        $data = $form->getData();
                        $user->state        = UserStructure::STATE_ACTIVE;
                        $user->confirmed    = true;
                        $user->password     = $data['password'];

                        if ( $user->save() )
                        {
                            $confirm->delete( $hash );
                            $success = true;
                        }
                    }
                    else
                    {
                        $success = false;
                    }
                }
            }
            else
            {
                $failed = true;
            }
        }
        else
        {
            $failed = true;
        }

        if ( $failed === true )
        {
            $this->messenger()
                 ->add( 'user.form.passwordChange.failed',
                        'user', Message::LEVEL_ERROR );

            return $this->redirect()
                        ->toRoute( 'Grid\User\PasswordChangeRequest\Create', array(
                            'locale'    => (string) $this->locale(),
                            'returnUri' => '/',
                        ) );
        }

        if ( $success === true )
        {
            $this->messenger()
                 ->add( 'user.form.passwordChange.success',
                        'user', Message::LEVEL_INFO );

            return $this->redirect()
                        ->toRoute( 'Grid\User\Authentication\Login', array(
                            'locale'    => (string) $this->locale(),
                            'returnUri' => '/',
                        ) );
        }

        if ( $success === false )
        {
            $this->messenger()
                 ->add( 'user.form.passwordChange.resolve.failed',
                        'user', Message::LEVEL_ERROR );
        }

        $this->paragraphLayout();

        return new MetaContent( 'user.passwordChangeRequest', array(
            'success'   => $success,
            'form'      => $form,
        ) );
    }
public function resolveAction ( ) { $ success = null ; $ failed = null ; $ service = $ this -> getServiceLocator ( ) ; $ userModel = $ service -> get ( 'Grid\User\Model\User\Model' ) ; $ confirm = $ service -> get ( 'Grid\User\Model\ConfirmHash' ) ; $ hash = $ this -> params ( ) -> fromRoute ( 'hash' ) ; if ( $ confirm -> has ( $ hash ) && ( $ email = $ confirm -> find ( $ hash ) ) ) { $ user = $ userModel -> findByEmail ( $ email ) ; if ( ! empty ( $ user ) && $ user -> state != UserStructure :: STATE_BANNED ) { $ request = $ this -> getRequest ( ) ; $ data = $ request -> getPost ( ) ; $ form = $ service -> get ( 'Form' ) -> get ( 'Grid\User\PasswordChangeRequest\Resolve' ) ; if ( $ request -> isPost ( ) ) { $ form -> setData ( $ data ) ; if ( $ form -> isValid ( ) ) { $ data = $ form -> getData ( ) ; $ user -> state = UserStructure :: STATE_ACTIVE ; $ user -> confirmed = true ; $ user -> password = $ data [ 'password' ] ; if ( $ user -> save ( ) ) { $ confirm -> delete ( $ hash ) ; $ success = true ; } } else { $ success = false ; } } } else { $ failed = true ; } } else { $ failed = true ; } if ( $ failed === true ) { $ this -> messenger ( ) -> add ( 'user.form.passwordChange.failed' , 'user' , Message :: LEVEL_ERROR ) ; return $ this -> redirect ( ) -> toRoute ( 'Grid\User\PasswordChangeRequest\Create' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'returnUri' => '/' , ) ) ; } if ( $ success === true ) { $ this -> messenger ( ) -> add ( 'user.form.passwordChange.success' , 'user' , Message :: LEVEL_INFO ) ; return $ this -> redirect ( ) -> toRoute ( 'Grid\User\Authentication\Login' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'returnUri' => '/' , ) ) ; } if ( $ success === false ) { $ this -> messenger ( ) -> add ( 'user.form.passwordChange.resolve.failed' , 'user' , Message :: LEVEL_ERROR ) ; } $ this -> paragraphLayout ( ) ; return new MetaContent ( 'user.passwordChangeRequest' , array ( 'success' => $ success , 'form' => $ form , ) ) ; }
Resolve a password-request
Resolve a password - request