Esempio n. 1
0
    /**
     * Pre dispatch method
     */
    public function preDispatch()
    {
        $this->View()->setScope(Enlight_Template_Manager::SCOPE_PARENT);

        $this->View()->sUserLoggedIn = $this->admin->sCheckUser();
        $this->View()->sUserData = $this->getUserData();
    }
Esempio n. 2
0
	/**
	 * Login account by ajax request
	 */
	public function ajaxLoginAction()
	{
		Enlight()->Plugins()->Controller()->Json()->setPadding();

        // Fix same origin miss match
        $response = $this->Response();
        $shop = Shopware()->Shop();
        if ($shop->getSecure()) {
            $response->setHeader(
                'Access-Control-Allow-Origin',
                'http://' . $shop->getHost()
            );
            $response->setHeader(
                'Access-Control-Allow-Methods', 'POST, GET'
            );
            $response->setHeader(
                'Access-Control-Allow-Credentials', 'true'
            );
        }

		if($this->admin->sCheckUser()) {
			return $this->View()->setTemplate();
		}

		if(!$this->Request()->getParam('accountmode')) {
			return;
		}

		if (empty(Shopware()->Session()->sRegister)) {
			Shopware()->Session()->sRegister = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
		}

		$this->admin->sSYSTEM->_POST = array();
		$this->admin->sSYSTEM->_POST['email'] = $this->Request()->getParam('email');
		$this->admin->sSYSTEM->_POST['password'] = $this->Request()->getParam('password');

		if($this->Request()->getParam('accountmode')==0 || $this->Request()->getParam('accountmode')==1) {
			Shopware()->Session()->sRegister['auth']['email'] = $this->admin->sSYSTEM->_POST['email'];
			Shopware()->Session()->sRegister['auth']['accountmode'] = (int) $this->Request()->getParam('accountmode');

			$this->View()->setTemplate();
		} else {
			$checkData = $this->admin->sLogin();

			if (empty($checkData['sErrorMessages'])) {
                $this->refreshBasket();
				$this->View()->setTemplate();
			} else {
				$this->View()->sFormData = $this->Request()->getParams();
				$this->View()->sErrorFlag = $checkData['sErrorFlag'];
				$this->View()->sErrorMessages = $checkData['sErrorMessages'];
			}
		}
	}
Esempio n. 3
0
 /**
  * @covers sAdmin::sSaveRegister
  */
 public function testsSaveRegister()
 {
     // Prepare all needed test structures for login
     $testData = array('auth' => array('email' => uniqid() . '*****@*****.**', 'password' => 'fooobar', 'accountmode' => 1, 'encoderName' => 'bcrypt'), 'billing' => array('salutation' => 'testsalutation', 'firstname' => 'testfirstname', 'lastname' => 'testlastname', 'street' => 'teststreet', 'streetnumber' => 'teststreetnumber', 'zipcode' => 'testzipcode', 'city' => 'testcity', 'country' => 'testcountry'), 'payment' => array('object' => array('id' => 2)));
     $this->module->sSYSTEM->sSESSION_ID = uniqid();
     $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID);
     $this->session->offsetSet('sRegister', $testData);
     // Test that login was successful
     $this->assertEmpty($this->session->offsetGet('sUserId'));
     $this->assertFalse($this->module->sCheckUser());
     $this->assertTrue($this->module->sSaveRegister());
     $userId = $this->session->offsetGet('sUserId');
     $this->assertEquals($userId, Shopware()->Db()->fetchOne('SELECT id FROM s_user WHERE id = ?', array($userId)));
     $this->assertNotEmpty($this->session->offsetGet('sUserId'));
     $this->assertTrue($this->module->sCheckUser());
     // Logout and delete data
     Shopware()->Session()->unsetAll();
     Shopware()->Db()->delete('s_user_attributes', 'userID = ' . $userId);
     Shopware()->Db()->delete('s_user', 'id = ' . $userId);
 }