/** * CCAuth::sign_in and sign_out tests */ public function test_sign() { $this->assertFalse(CCAuth::valid()); $this->assertTrue(CCAuth::sign_in(static::$current_user)); $this->assertTrue(CCAuth::valid()); $this->assertFalse(CCAuth::sign_out()); }
/** * Sign up action * * @return CCResponse */ public function action_sign_up() { // When the user is already authenticated we redirect him home. if (CCAuth::valid()) { return CCRedirect::to('/'); } $this->theme->topic = __(':action.topic'); $this->view = $this->theme->view('auth/sign_up.view'); // create a new user object as data holder $user = new User(); // bind the newly created user object to our view $this->view->bind('user', $user); if (CCIn::method('post')) { // Lets assign the email and the password to our // user object using the stirct assign method wich // will ignore all other post values in the assing process. $user->strict_assign(array('email', 'password'), CCIn::all('post')); $validator = CCValidator::post(); // assign the labels to the validator this way we get // correct translated error messages. $validator->label(array('email' => __('model/user.label.email'), 'password' => __('model/user.label.password'), 'password_match' => __('model/user.label.password_match'))); // does the user already exist $validator->set('same_email', User::find('email', $user->email)); $validator->message(__(':action.message.email_in_use'), 'negative', 'same_email'); // validate the other fields $validator->rules('email', 'required', 'email'); $validator->rules('password', 'required', 'min:6'); $validator->rules('password_match', 'required', 'match:password'); // when the data passes the validation if ($validator->success()) { // because the user input is correct we can now save the // object to the database and sign the user in. $user->save(); CCAuth::sign_in($user); UI\Alert::flash('success', __(':action.message.success')); return CCRedirect::to('/'); } else { UI\Alert::add('danger', $validator->errors()); } } }
<span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="<?php echo to('/'); ?> "><?php echo App::name(); ?> </a> </div> <div class="collapse navbar-collapse" id="ccf-navbar"> <ul class="nav navbar-nav"> <?php if (CCAuth::valid()) { ?> <li> <a href="<?php echo to('@auth.sign_out'); ?> ">Sign Out</a> </li> <?php } else { ?> <li> <a href="<?php echo to('@auth.sign_in'); ?> ">Sign In</a>