/** * Attempt to do login * */ public function postLogin() { $input = array('email' => Input::get('email'), 'password' => Input::get('password'), 'remember' => Input::get('remember')); // If you wish to only allow login from confirmed users, call logAttempt // with the second parameter as true. // logAttempt will check if the 'email' perhaps is the username. // Check that the user is confirmed. if (Confide::logAttempt($input, true)) { // added login activity DB::update('UPDATE users SET last_login = ? WHERE id = ?', array(date('Y-m-d H:i:s', time()), Auth::user()->id)); $r = Session::get('loginRedirect'); if (!empty($r)) { Session::forget('loginRedirect'); return Redirect::to($r); } return Redirect::to('/admin'); } else { // Check if there was too many login attempts if (Confide::isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($this->user->checkUserExists($input) && !$this->user->isConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } return Redirect::to('user/login')->withInput(Input::except('password'))->with('error', $err_msg); } }
/** * Attempt to do login * */ public function postLogin() { $input = array('email' => Input::get('email'), 'password' => Input::get('password'), 'remember' => Input::get('remember')); if (Confide::logAttempt($input, true)) { DB::update('UPDATE users SET last_login = ? WHERE id = ?', array(date('Y-m-d H:i:s', time()), Auth::user()->id)); Activity::log(array('contentID' => Confide::user()->id, 'contentType' => 'login', 'description' => 'info', 'details' => gethostbyaddr($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] . ' (' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ')' : $_SERVER['REMOTE_ADDR'], 'updated' => Confide::user()->id ? true : false)); Event::fire('user.login', array($input)); $r = Session::get('loginRedirect'); if (!empty($r)) { Session::forget('loginRedirect'); return Redirect::to($r); } return Redirect::to('/admin'); } else { // Check if there was too many login attempts if (Confide::isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($this->user->checkUserExists($input) && !$this->user->isConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } return Redirect::to('user/login')->withInput(Input::except('password'))->with('error', $err_msg); } }
public static function login($result, $token, $token_exp) { if ($result->id) { $user = User::checkUserExists($result->id); if (!$user) { $user = new User(); $user->name = $result->firstName . " " . $result->lastName; $user->linkedin_id = $result->id; $user->pic_url = $result->pictureUrl; $user->profile_url = $result->publicProfileUrl; $user->api_url = $result->apiStandardProfileRequest->url; $user->linkedin_token = $token; $user->linkedin_token_exp = date("Y-m-d H:i:s", $token_exp); $user->company_id = Company::getPublicUserCompanyId(); $user->save(TRUE); } else { $user->linkedin_token = $token; $user->linkedin_token_exp = date("Y-m-d H:i:s", $token_exp); $user->save(FALSE); } HttpSession::setUser($user); //if user is a student, lets extract linkedin full profile if ($user->company_id == 2) { Student::getByUserId($user->id)->extractFromLinkedin(); } return true; } else { return false; } }
/** * Attempt to do login * */ public function postLogin() { $repo = App::make('UserRepository'); $input = Input::all(); if ($repo->login($input)) { return Redirect::intended('/'); } else { if ($repo->isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($repo->existsButNotConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } return Redirect::action('UsersController@login')->withInput(Input::except('password'))->with('error', $err_msg); } $input = array('email' => Input::get('email'), 'username' => Input::get('email'), 'password' => Input::get('password'), 'remember' => Input::get('remember')); // If you wish to only allow login from confirmed users, call logAttempt // with the second parameter as true. // logAttempt will check if the 'email' perhaps is the username. // Check that the user is confirmed. if (Confide::logAttempt($input, true)) { return Redirect::intended('/'); } else { // Check if there was too many login attempts if (Confide::isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($this->user->checkUserExists($input) && !$this->user->isConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } return Redirect::to('user/login')->withInput(Input::except('password'))->with('error', $err_msg); } }
/** * Attempt to do login * */ public function postLogin() { $input = array('email' => Input::get('email'), 'username' => Input::get('email'), 'password' => Input::get('password'), 'remember' => Input::get('remember')); // If you wish to only allow login from confirmed users, call logAttempt // with the second parameter as true. // logAttempt will check if the 'email' perhaps is the username. // Get the value from the config file instead of changing the controller if (Confide::logAttempt($input, Config::get('confide::signup_confirm'))) { // Redirect the user to the URL they were trying to access before // caught by the authentication filter IE Redirect::guest('user/login'). // Otherwise fallback to '/' // Fix pull #145 return Redirect::intended('/users'); // change it to '/admin', '/dashboard' or something } else { $user = new User(); // Check if there was too many login attempts if (Confide::isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($user->checkUserExists($input) and !$user->isConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } return Redirect::to('/')->withInput(Input::except('password'))->with('error', $err_msg); } }
public function login($input) { // If you wish to only allow login from confirmed users, call logAttempt // with the second parameter as true. // logAttempt will check if the 'email' perhaps is the username. if (Confide::logAttempt($input, Config::get('confide::login_confirmed'))) { $this->setToken(); return true; } else { $user = new User(); // Check if there was too many login attempts if (Confide::isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($user->checkUserExists($input) and !$user->isConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } return $err_msg; } }
require_once DOC_ROOT . '/includes/classes/class.user.php'; $new_user = new User(); $new_signup = '/signup_pending.php'; if (!empty($_POST)) { $error = array(); $mobile_phone = get_param('mobile_phone'); $password = get_param('password'); $conf_password = get_param('conf_password'); $firstname = get_param('firstname'); $lastname = get_param('lastname'); $signup_data = array('firstname' => $firstname, 'lastname' => $lastname); if (empty($mobile_phone)) { $error['phone_empty'] = true; } elseif (false == User::validate_phone($mobile_phone)) { $error['phone_invalid'] = true; } elseif (User::checkUserExists($mobile_phone)) { $error['phone_exists'] = true; } if (empty($password)) { $error['password_empty'] = true; } elseif ($password != $conf_password) { $error['password_unmatched'] = true; } elseif (strlen($password) < 6 || strlen($password) > 15) { $error['password_length'] = true; } if (empty($firstname)) { $error['firstname'] = true; } if (empty($lastname)) { $error['lastname'] = true; }
public function do_login() { $username = Input::get('username'); $input = array('email' => Input::get('username'), 'username' => Input::get('username'), 'password' => Input::get('password'), 'remember' => Input::get('remember')); // get username from fetched data on DB $fetched_user = User::whereUsername($username)->get(); foreach ($fetched_user as $key) { $fetched_username = $key->username; $status = $key->confirmed; } // Authenticate User if (Confide::logAttempt($input)) { // compare input username on fetched username $result = strcmp($fetched_username, $username); if ($result == 0) { if ($status == 0) { Confide::logout(); $err_msg2 = "Your account has been deactivated. Please contact authorized Personnel"; return Redirect::to('login')->withInput(Input::except('password'))->with('deactivated', $err_msg2); } return Redirect::intended('dashboard'); } Confide::logout(); $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); return Redirect::to('login')->withInput(Input::except('password'))->with('error', $err_msg); } else { $user = new User(); // Check if there was too many login attempts if (Confide::isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($user->checkUserExists($input) and !$user->isConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } return Redirect::action('UserController@login')->withInput(Input::except('password'))->with('error', $err_msg); } }
/** * Log the user in */ public function do_login() { $rules = ['username' => 'required', 'password' => 'required']; $validate = Hyfn::validate($rules); if ($validate !== true) { $user = new User(); return Redirect::to('login')->withInput(Input::except('password'))->withErrors($validate->errors()); } $input = array('email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Input::get('password'), 'remember' => Input::get('remember')); // If you wish to only allow login from confirmed users, call logAttempt // with the second parameter as true. // logAttempt will check if the 'email' perhaps is the username. if (Confide::logAttempt($input)) { // If the session 'loginRedirect' is set, then redirect // to that route. Otherwise redirect to '/' $r = Session::get('loginRedirect'); if (!empty($r)) { Session::forget('loginRedirect'); return Redirect::to($r); } return Redirect::to('/'); // change it to '/admin', '/dashboard' or something } else { $user = new User(); // Check if there was too many login attempts if (Confide::isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($user->checkUserExists($input) and !$user->isConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } $user->validationErrors->add('login_error', $err_msg); return Redirect::to('admin/login')->withInput(Input::except('password'))->with('error', true)->withErrors($user->errors()); } }
public function socialLogin($action = "") { if ($action == "auth") { // process authentication try { Hybrid_Endpoint::process(); } catch (Exception $e) { // redirect back to http://URL/social/ return Redirect::route('hybridauth'); } return; } try { // create a HybridAuth object $socialAuth = new Hybrid_Auth(app_path() . '/config/hybridauth.php'); if ($action == 'google') { $provider = $socialAuth->authenticate("Google"); } else { if ($action == 'facebook') { $provider = $socialAuth->authenticate("facebook"); } } // fetch user profile $userProfile = $provider->getUserProfile(); // logout $provider->logout(); } catch (Exception $e) { // exception codes can be found on HybBridAuth's web site return $e->getMessage(); } //check user to login or create new $user = User::where('email', $userProfile->email)->first(); if (isset($user->email)) { //can update user and login $user->lastest_login = date("Y-m-d H:i:s"); if ($action == 'facebook' && empty($user->facebook_id)) { $user->facebook_id = $userProfile->identifier; $user->save(); } elseif ($action == 'google' && empty($user->google_id)) { $user->google_id = $userProfile->identifier; $user->save(); } //return Redirect::to('/login')->with('notice',Lang::get('user_texts.social_is_exist')); if (!empty($user->authy)) { $authcontroller = new AuthController(); $auth_controller = $authcontroller->getAuthy(); $requestSms = $auth_controller->requestSms($user->authy); // echo "<pre>errors: "; print_r($requestSms->errors()); echo "</pre>"; // echo "<pre>requestSms: "; print_r($requestSms); echo "</pre>"; if ($requestSms->ok()) { //$notices = $requestSms->ok(); //return true return Redirect::to('sms-verify')->with('authy_id', $user->authy)->with('user_login', $user->id); } else { //not_sent_token $errors = $requestSms->errors(); return Redirect::to('login')->with('error', $errors->message); } } else { Auth::login($user); return Redirect::to('/'); } } else { //create new user and login $user = new User(); $user->firstname = $userProfile->firstName; $user->lastname = $userProfile->lastName; $user->email = $userProfile->email; $user->username = $userProfile->identifier; $user->password = $userProfile->identifier; $user->password_confirmation = $userProfile->identifier; $user->banned = 0; $user->confirmed = 1; $user->referral = ''; $trade_key = md5($user->username . $user->email . time()); $user->trade_key = $trade_key; $user->ip_lastlogin = $this->get_client_ip(); $user->lastest_login = date("Y-m-d H:i:s"); if ($action == 'facebook' && empty($user->facebook_id)) { $user->facebook_id = $userProfile->identifier; } elseif ($action == 'google' && empty($user->google_id)) { $user->google_id = $userProfile->identifier; } $user->save(); // echo "<pre>user2" . print_r( $user->email, true ) . "</pre><br />"; if ($user->id) { $user->addRole('User'); $input = array('email' => $userProfile->email, 'username' => $userProfile->email, 'password' => $userProfile->identifier, 'remember' => 0); //login if ($c = Confide::logAttempt($input, Config::get('confide::signup_confirm'))) { return Redirect::to('/'); } else { $user = new User(); // Check if there was too many login attempts if (Confide::isThrottled($input)) { $err_msg = Lang::get('confide::confide.alerts.too_many_attempts'); } elseif ($user->checkUserExists($input) and !$user->isConfirmed($input)) { $err_msg = Lang::get('confide::confide.alerts.not_confirmed'); } else { $err_msg = Lang::get('confide::confide.alerts.wrong_credentials'); } return Redirect::action('UserController@login')->with('error', $err_msg); } } else { $error = $user->errors()->all(':message'); return Redirect::to('user/register')->withInput(Input::except('password'))->with('error', $error); } } }