/** * Sign in action * * @return CCResponse */ public function action_sign_in() { // Here we set the page topic seen in the title tag $this->theme->topic = __(':action.topic'); // lets assign the view. Instead of getting the view directly // using CCView::create( 'path/to/view' ) we get the view from the // theme this allows us to have a diffrent sign_in for every theme. // If the view does not exist in the theme it will load the view from // the default view folder. $this->view = $this->theme->view('auth/sign_in.view'); $this->view->last_identifier = CCIn::post('identifier'); // By checking the HTTP method we figure out if this is a post request or not. if (CCIn::method('post')) { // Validate the data and get the user object. // We use the key "identifier" because you can configure on // what fields the user is able to login. You could add for example // the username or the customer number etc. if ($user = CCAuth::validate(CCIn::post('identifier'), CCIn::post('password'))) { // sign in the user with the current session. CCAuth::sign_in($user); // flash a success message to the user that he has been // logged in succesfully. UI\Alert::flash('success', __(':action.message.success')); // Redirect the user back to the url where he came from // this will only work when the next get parameter is set. return CCRedirect::next(); } // If we could not recive a user object the login data were clearly invalid. UI\Alert::add('danger', __(':action.message.invalid')); } }
/** * CCValidator::post tests */ public function test_post() { CCIn::instance(new CCIn_Instance(array(), array('agb' => 1), array(), array(), array())); $validator = CCValidator::post(array('agb' => (bool) CCIn::post('agb'))); $this->assertTrue($validator instanceof CCValidator); $this->assertInternalType('bool', $validator->data('agb')); $this->assertTrue($validator->data('agb')); }
/** * Test input POST */ public function testPost() { // generate server data $this->fakeServerData(); // check post params $this->assertEquals(CCIn::post('hello'), 'world'); // check post param default $this->assertEquals(CCIn::post('not_existing', 'test'), 'test'); // check post param has $this->assertFalse(CCIn::has_post('not_existing')); // check post param has $this->assertTrue(CCIn::has_post('hello')); }