function login() { $this->template->set_layout('frontend'); $this->template->title('Login'); //validate form input $this->form_validation->set_rules('identity', 'lang:web_email', 'required|valid_email|trim|xss_clean'); $this->form_validation->set_rules('password', 'lang:web_password', 'required|trim|xss_clean'); $this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>'); if ($this->form_validation->run() == true) { //check to see if the user is logging in if (User::validate_login($this->input->post('identity'), $this->input->post('password'))) { //if the login is successful $this->sangar_auth->register_session(); //redirect them back to the home page $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('web_login_correct'))); redirect('admin', 'refresh'); } else { //if the login was un-successful //redirect them back to the login page $this->session->set_flashdata('message', array('type' => 'warning', 'text' => lang('web_login_incorrect'))); redirect('login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries } } else { //the user is not logging in so display the login page //set the flash data error message if there is one $this->template->set('message', validation_errors() ? validation_errors() : $this->session->flashdata('message')); $this->template->set('identity', array('name' => 'identity', 'id' => 'identity', 'type' => 'text', 'value' => $this->form_validation->set_value('identity'))); $this->template->set('password', array('name' => 'password', 'id' => 'password', 'type' => 'password')); //$layout['body'] = $this->load->view('users/login', $this->data, TRUE); //$this->load->view('layouts/login', $layout); $this->template->build('users/login'); } }
public function login() { $param = array(); if (isset($_POST['username'])) { Load::model('user'); $User = new User(); if ($User->validate_login($_POST)) { Load::redirect('admin/dashboard'); } else { $param = array("msg" => "Wrong username and password."); } } Load::view('login', $param); Load::hook_footer('signin'); }
public function index() { $this->loadModel(SLASH . 'users' . SLASH . 'user'); $user = new User(); $status = 0; $status = $user->validate_login(); switch ($status) { case LOGIN_INVALID: if (isset($_POST['login'])) { setMessage("Username or Password is incorrect."); } $this->addJS('/js/login.js'); $this->loadView(SLASH . 'users' . SLASH . 'signin'); exit; break; case LOGIN_DISABLED: setMessage("User account has been disabled."); gotoUrl('/?route=/users/users&m=logout'); exit; break; case LOGIN_RESET: setMessage("A password reset has been requested."); gotoUrl('/?route=/users/users&m=changepwd'); exit; break; case LOGIN_SUCCESS: // successful login, do nothing; break; default: setMessage("Something bad has happened. Head for the hills."); gotoUrl('/'); exit; break; } if (isset($_SESSION[APP_SES . 'route']) && !empty($_SESSION[APP_SES . 'route'])) { gotoUrl('/?route=' . $_SESSION[APP_SES . 'route']); } $this->setTitle("User Options"); if ($_SESSION[APP_SES . 'user_type'] > self::power_user) { $this->loadPartView(SLASH . 'users' . SLASH . 'admin_pages', TRUE); $this->loadPartView(SLASH . 'users' . SLASH . 'user_pages', FALSE); } else { $this->loadPartView(SLASH . 'users' . SLASH . 'user_pages', TRUE); } $this->loadPartView(SLASH . 'users' . SLASH . 'index', FALSE); $this->endView(); }
function login() { $this->view_data['error'] = "false"; $this->theme_view = 'login'; if ($_POST) { $user = User::validate_login($_POST['username'], $_POST['password']); if ($user) { if ($this->input->cookie('fc2_link') != "") { redirect($this->input->cookie('fc2_link')); } else { redirect(''); } } else { $this->view_data['error'] = "true"; $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_login_incorrect')); } } }
public function processLogin() { $validator = User::validate_login($data = Input::all()); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(Input::except('password')); } else { $user = User::where('email', '=', $data['email_or_username'])->orWhere('username', $data['email_or_username'])->first(); // Check if user found in DB if ($user) { // Check if user is activated if ($user->activated == 0) { return Redirect::back()->withActivationMessage(Lang::get('larabase.unactivated_account')); } // Check if user is suspended $suspend_duration = '15'; if ($user->throttle->suspended) { // Find time since last login attempt. Throttle login if it is less than suspend_duration if ($user->throttle->last_attempt->diffInMinutes(Carbon\Carbon::now()) < $suspend_duration) { return Redirect::back()->withWarning(Lang::get('larabase.account_suspended', ['suspend_duration' => $suspend_duration])); } Event::fire('user.revoke_suspend', [$user->id]); } // Check if user is banned if ($user->throttle->banned) { return Redirect::back()->withWarning(Lang::get('larabase.account_banned')); } // Attempt to authenticate the User $attempt = Auth::attempt(['email' => $user->email, 'password' => $data['password']], Input::get('remember')); if ($attempt) { Event::fire('auth.login', array($user)); return Redirect::intended('dashboard')->withSuccess(Lang::get('larabase.login_success')); } // On failed login attempt, update the Throttle table DB::table('throttle')->whereUserId($user->id)->update(['last_attempt' => new DateTime()]); if ($user->throttle->attempts == 5) { DB::table('throttle')->whereUserId($user->id)->update(['suspended' => TRUE, 'attempts' => '0', 'last_attempt' => new DateTime()]); } DB::table('throttle')->whereUserId($user->id)->increment('attempts'); return Redirect::back()->withInput(Input::except('password'))->withError(Lang::get('larabase.invalid_credentials')); } return Redirect::back()->withInput(Input::except('password'))->withError(Lang::get('larabase.invalid_credentials')); } }
public function index() { if ($_POST) { $username = $this->input->post('login_username'); $password = $this->input->post('login_pass'); $valid_login = User::validate_login($username, $password); if ($valid_login) { $this_user = User::find_by_username($username); $user_level = Usermeta::get_user_level($this_user->id); $session_data = array('user_id' => $this_user->id, 'username' => $this_user->username, 'password' => $this_user->password, 'email' => $this_user->email, 'display_name' => $this_user->display_name, 'user_level' => $user_level, 'chat_color' => get_chat_color(intval($user_level)), 'redirect' => $this->session->userdata('redirect')); $this->session->set_userdata($session_data); redirect($this->session->userdata('redirect')); } else { $this->content_view = 'login_error'; } } else { redirect('home'); } }
public function login() { $this->layout = 'blank'; $user = new User(_post('user')); $user->refine(); if (!$user->validate_login()) { $this->flash->add('message_error', $user->errors->get_messages()); $this->back(); } $remember_me = is_blank(_post('remember_me')) ? false : true; $user->login($remember_me); $return_url = _get('return_url'); if (empty($return_url)) { $return_url = '/'; } $this->redirect_to($return_url); }
function test_invalid_login() { $login = User::validate_login($this->m_data['username'], random_string('alnum', 8)); $this->_assert_false($login); }
<?php //if logout action if (isset($_GET['action'])) { if ($_GET['action'] == 'logout') { //kill cookies setcookie('user_id', '', time() - 60 * 60 * 24 * 1, '/'); setcookie('users_user_types', '', time() - 60 * 60 * 24 * 1, '/'); header("Location: login.php"); } } include_once 'classes/user.php'; //user login $user_info = User::validate_login($_POST['username'], $_POST['password']); //if valid login if ($user_info->num_rows > 0) { //retrieve info $user_info = mysqli_fetch_assoc($user_info); //set user_id cookie setcookie('user_id', $user_info['User_ID'], time() + 60 * 60 * 24 * 1, '/'); //set permissions setcookie('users_user_types', base64_encode(serialize(User::get_users_user_types($user_info['User_ID']))), time() + 60 * 60 * 24 * 1, '/'); //forward to main page header("Location: index.php"); } include 'include/header.php'; ?> <br /> <script> $(document).ready(function() {
/** * Get controller name from route get variable * Also, find method name from m get variable * And find variables from v get variable * @method __construct * @return void */ function __construct() { if (isset($_GET['route'])) { $uri = $_GET['route']; } else { $uri = "/application/schnippets"; } $this->loadAssets(); $uri = $this->filterURI($uri); $parts = explode('/', $uri); //check for default site controller first if (is_dir('protected' . SLASH . 'controller' . SLASH . $parts[1])) { if (is_file('protected' . SLASH . 'controller' . SLASH . $parts[1] . SLASH . $parts[2] . '.php')) { $this->file = 'protected' . SLASH . 'controller' . SLASH . $parts[1] . SLASH . $parts[2] . '.php'; $this->class = $this->filterClass($parts[1] . $parts[2]); } } else { //check for plugin site controller next if (is_dir('protected' . SLASH . 'plugin' . SLASH . $parts[1])) { if (is_file('protected' . SLASH . 'plugin' . SLASH . $parts[1] . SLASH . 'controller' . SLASH . $parts[2] . '.php')) { $this->file = 'protected' . SLASH . 'plugin' . SLASH . $parts[1] . SLASH . 'controller' . SLASH . $parts[2] . '.php'; $this->class = $this->filterClass($parts[1] . $parts[2]); } } } if (isset($_GET['m'])) { $this->method = $_GET['m']; } else { $this->method = ""; } if (isset($_GET['v'])) { $this->var = $_GET['v']; } if (isset($_COOKIE[APP_SES . 'id'])) { $this->loadModel('/users/user'); $user = new User(); $user->validate_login(); } }