/**
  * 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);
     }
 }
Example #3
0
 /**
  * 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);
     }
 }
include 'Sorteios.php';
include 'Participantes.php';
include 'Ganhadores.php';
include 'Checkout.php';
include 'Vendas.php';
include 'Cadastros.php';
include 'ProdutosInfo.php';
$querys = new Querys();
// Inicia Classe Querys
$session = new Session();
// Inicia Classe Session
$session->StartSession();
// Inicia SESSION
$user = new User();
// Inicia Classe User
$sorteios = new Sorteios();
$participantes = new Participantes();
$ganhadores = new Ganhadores();
$produtos_info = new ProdutosInfo();
$vendas = new Vendas();
if (!isset($session->data['user']['user_login']) and !isset($session->data['user']['user_cpf'])) {
    $session->Destroy('user');
} else {
    $user->CheckLogin($session->data);
    if ($user->isLoggedUser()) {
        if ($user->isConfirmed() == '0') {
            $S_NotConfirmed = true;
        }
        $S_UserLogin = $user->isLoggedUser();
    }
}
    // fatal
    // redisplay login page
    $page = new PageLoginScreen(isset($_GET['redirect']) ? $_GET['redirect'] : '');
    echo $page->create();
    exit;
}
// create user class with email
$user = new User(StringHelper::cleanGPC($_POST['user_email']));
// was the email correct?
if ($user->id !== null) {
    // was the password correct?
    if ($user->login(StringHelper::cleanGPC($_POST['user_password']))) {
        $_SESSION['user'] =& $user;
        $options = new Options($user);
        if ($user->getType() == 'register') {
            if ($user->isConfirmed()) {
                // New User -> Attach Contact
                if ($user->attachContact()) {
                    $flag = 'found';
                } else {
                    $flag = 'created';
                }
                $page = new PageRegister('confirm', $flag, isset($_GET['redirect']) ? $_GET['redirect'] : '');
                echo $page->create();
                exit;
            } else {
                // User#136 has set an error message; redisplay login page
                $page = new PageLoginScreen(isset($_GET['redirect']) ? $_GET['redirect'] : '');
                echo $page->create();
                exit;
            }
 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;
     }
 }
 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());
     }
 }
Example #10
0
 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);
         }
     }
 }
 /**
  * logs user in after creating the User object from $_SERVER['SSL_CLIENT_S_DN_Email'] if possible
  *
  * @return User object or NULL
  * @static
  */
 function sslCertificateLogin()
 {
     $user = new User($_SERVER['SSL_CLIENT_S_DN_Email']);
     if ($user->id && $user->isConfirmed()) {
         //echo 'SSL Login: '******'UPDATE ' . TABLE_USERS . ' SET lastLogin=NOW(), failedLogins=0, lastRemoteIP="' . $_SERVER['REMOTE_ADDR'] . '" 
             WHERE userid = ' . $db->escape($user->id));
         return $user;
     }
     return NULL;
 }