PHP Method User::authenticate, codiad Code Examples

This page contains top rated real world PHP examples of method User::authenticate from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: user_controller.php Project: LowellaMercurio/board-1
0
 /**
  * To check if username is valid and existing
  * To check if username and password matched
  * Validation to proceed to Thread page
  **/
 public function index()
 {
     $username = Param::get('login_name');
     $password = Param::get('login_pword');
     $user = new User();
     $login_info = array('username' => $username, 'password' => $password);
     if (!array_filter($login_info)) {
         $status = "";
     } else {
         try {
             foreach ($login_info as $key => $value) {
                 if (!is_complete($value)) {
                     throw new ValidationException("Please fill up all fields");
                 }
             }
             $user_login = $user->authenticate($username, $password);
             $_SESSION['username'] = $user_login->username;
             redirect(url('thread/index'));
         } catch (ValidationException $e) {
             $status = notice($e->getMessage(), "error");
         } catch (RecordNotFoundException $e) {
             $status = notice($e->getMessage(), "error");
         }
     }
     $this->set(get_defined_vars());
 }
Example #2
Show file File: FrontendHelperUser.php Project: madeyourday/contao-rocksolid-frontend-helper
0
 /**
  * Disable BackendUser authentication redirect and cache the result
  */
 public function authenticate()
 {
     if ($this->frontendHelperUserAuthenticated === null) {
         $this->frontendHelperUserAuthenticated = \User::authenticate();
     }
     return $this->frontendHelperUserAuthenticated;
 }
Example #3
Show file File: ApplicationController.php Project: JCQS04/myimouto
0
 protected function set_current_user()
 {
     $user = null;
     $AnonymousUser = array('id' => 0, 'level' => 0, 'name' => "Anonymous", 'show_samples' => true, 'language' => '', 'secondary_languages' => '', 'pool_browse_mode' => 1, 'always_resize_images' => true, 'ip_addr' => $this->request()->remoteIp());
     if (!current_user() && $this->session()->user_id) {
         $user = User::where(['id' => $this->session()->user_id])->first();
     } else {
         if ($this->cookies()->login && $this->cookies()->pass_hash) {
             $user = User::authenticate_hash($this->cookies()->login, $this->cookies()->pass_hash);
         } elseif (isset($this->params()->login) && isset($this->params()->password_hash)) {
             $user = User::authenticate($this->params()->login, $this->params()->password_hash);
         } elseif (isset($this->params()->user['name']) && isset($this->params()->user['password'])) {
             $user = User::authenticate($this->params()->user['name'], $this->params()->user['password']);
         }
         $user && $user->updateAttribute('last_logged_in_at', date('Y-m-d H:i:s'));
     }
     if ($user) {
         if ($user->is_blocked() && $user->ban && $user->ban->expires_at < date('Y-m-d H:i:s')) {
             $user->updateAttribute('level', CONFIG()->starting_level);
             Ban::destroyAll("user_id = " . $user->id);
         }
         $this->session()->user_id = $user->id;
     } else {
         $user = new User();
         $user->assignAttributes($AnonymousUser, ['without_protection' => true]);
     }
     User::set_current_user($user);
     $this->current_user = $user;
     # For convenient access in activerecord models
     $user->ip_addr = $this->request()->remoteIp();
     Moebooru\Versioning\Versioning::init_history();
     if (!current_user()->is_anonymous()) {
         current_user()->log($this->request()->remoteIp());
     }
 }
Example #4
Show file File: Views.php Project: hbasria/pjango
0
 function login($request)
 {
     $templateArr = array();
     $modelClass = 'User';
     $formData = array();
     if ($request->user->is_authenticated()) {
         HttpResponseRedirect(pjango_ini_get('LOGIN_REDIRECT_URL'));
     }
     if ($request->POST) {
         $form = new Pjango\Contrib\Auth\Forms\LoginForm($request->POST);
         try {
             if (!$form->is_valid()) {
                 throw new Exception(pjango_gettext('There are some errors, please correct them below.'));
             }
             $formData = $form->cleaned_data();
             $user = User::authenticate($formData['username'], $formData['password']);
             HttpResponseRedirect(pjango_ini_get('LOGIN_REDIRECT_URL'));
         } catch (Exception $e) {
             Messages::Error($e->getMessage());
         }
     }
     if (!$form) {
         $form = new Pjango\Contrib\Auth\Forms\LoginForm($formData);
     }
     $templateArr['addchange_form'] = $form->as_list();
     render_to_response('auth/login.html', $templateArr);
 }
Example #5
Show file File: BackendAdminController.php Project: OlesKashchenko/SkillsProject2
0
 public function postLogin()
 {
     $email = Input::get('email');
     $password = Input::get('password');
     if (User::authenticate(['email' => $email, 'password' => $password], Input::has('rememberme'))) {
         return Redirect::intended('/admin');
     }
     return Redirect::to('/login')->withInput()->withErrors('Такой связки email и пароля нет.');
 }
Example #6
Show file File: session.php Project: natureday1/Life
0
 public function create($username, $password)
 {
     $user = User::authenticate($username, $password);
     if ($user === false) {
         Redirect('session/create?error=yes');
     }
     $_SESSION['user'] = $user;
     Redirect('index.php');
 }
Example #7
Show file File: session_controller.php Project: tuureilmarinen/tsoha
0
 public static function store()
 {
     $user = User::authenticate($_POST['username'], $_POST['password']);
     if ($user) {
         $_SESSION['user'] = $user->id;
         Redirect::to("/task", array('message' => "Welcome back."));
     }
     View::make('session/new.html', array('errors' => array("Wrong password or username.")));
 }
Example #8
Show file File: user.php Project: Jonathan-Law/fhd
0
function register($info = null)
{
    $session = mySession::getInstance();
    if ($session->isLoggedIn()) {
        $session->logout();
    }
    if ($info !== null) {
        //check email and username they have to be unique
        $check = User::getUserByCred($info->email, $info->username);
        if (!$check) {
            $temp_user = new User();
            $temp_user->username = $info->username;
            $temp_user->email = $info->email;
            $temp_user->password = sha1($info->password);
            $temp_user->first_name = $info->first;
            $temp_user->last_name = $info->last;
            $temp_user->gender = $info->gender;
            $temp_user->rights = 'normal';
            $temp_user->status = 'current';
            $temp_user->valid = 1;
            $temp_user->save();
            $found_user = User::authenticate($temp_user->username, $temp_user->password);
            if ($found_user) {
                // log them in
                $session->login($found_user);
                // grab the account status
                $profile_status = $found_user->status;
                if ($profile_status != 'current') {
                    // their account isn't set up so log them out send them to the login page.
                    $session->logout();
                    $session->message("Creating your user profile failed");
                    return false;
                } else {
                    // send verification email.
                    $to = $found_user->email;
                    $check = substr($found_user->password, -12);
                    $subject = "familyhistorydatabase.org verification email";
                    $message = "You are now registered at familyhistorydatabase.org.\n";
                    $message = $message . "\nTo verify your membership click on the link below.\nIf you weren't requesting membership, please ignore this email, and we send our appologies!";
                    $message = $message . "\n" . APIURL . "user/validate/?id=" . $found_user->id . "&validate={$check}";
                    $from = "noreply@familyhistorydatabase.org";
                    $headers = "From:" . $from;
                    mail($to, $subject, $message, $headers);
                    unset($found_user->password);
                    return $found_user;
                }
            }
        } else {
            // If User Not Found
            return false;
        }
    } else {
        // If User Not Found
        return false;
    }
    exit;
}
Example #9
Show file File: UserController.php Project: hyttijan/MyImgur
0
 public static function login($parameters)
 {
     $id = User::authenticate($parameters);
     if ($id != null) {
         $content["success"] = "Login was succesful";
     } else {
         $content["error"] = "Login failed. Username/password combination was invalid.";
     }
     return $content;
 }
Example #10
Show file File: user_controller.php Project: laazz/talpa
0
 public static function login()
 {
     $params = $_POST;
     $user = User::authenticate($params['username'], $params['password']);
     if ($user) {
         $_SESSION['user'] = $user->id;
         Redirect::to(\Slim\Slim::getInstance()->urlFor('index'), array('message' => 'Olet kirjautunut sisään'));
     } else {
         Redirect::to(\Slim\Slim::getInstance()->urlFor('login'), array('message' => 'Kirjautuminen epäonnistui', 'error' => true));
     }
 }
Example #11
Show file File: user_controller.php Project: banjohirvi/Tsoha-Bootstrap
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['username'], $params['password']);
     if (!$user) {
         View::make('user/login.html', array('error' => 'Invalid username or password!', 'username' => $params['username']));
     } else {
         $_SESSION['user'] = $user->id;
     }
     Redirect::to('/', array('message' => 'Login successful!'));
 }
Example #12
Show file File: user_controller.php Project: saranas/Tsoha-Bootstrap
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['kayttajanimi'], $params['salasana']);
     if (!$user) {
         View::make('user/login.html', array('error' => 'Väärä käyttäjätunnus tai salasana!', 'kayttajanimi' => $params['kayttajanimi']));
     } else {
         $_SESSION['user'] = $user->kayttaja_id;
         Redirect::to('/', array('message' => 'Tervetuloa takaisin ' . $user->kayttajanimi . '!'));
     }
 }
Example #13
Show file File: user_controller.php Project: Rochet2/Tsoha-Bootstrap
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['username'], $params['password']);
     if (!$user) {
         Redirect::to('/user/login', array('errors' => array('Invalid username or password'), 'attr' => $_POST));
     } else {
         $_SESSION['user'] = $user->id;
         Redirect::to('/', array('message' => 'Welcome back ' . $user->name . '!'));
     }
 }
Example #14
Show file File: login_model.php Project: runningjack/RobertJohnson
0
 public function run($username, $password)
 {
     global $session;
     $userReg = User::authenticate($username, $password);
     if ($userReg) {
         $session->login($userReg);
         return true;
     } else {
         return false;
     }
 }
Example #15
Show file File: userController.php Project: Hecarrah/Tsoha-Bootstrap
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['username'], $params['password']);
     if (!$user) {
         View::make('user/login.html', array('error' => 'Väärä käyttätunnus tai salasana', 'username' => $params['username']));
     } else {
         $_SESSION['user'] = $user->id;
         Redirect::to('/memo', array('message' => 'Tervetuloa takaisin ' . $user->name . '.'));
     }
 }
Example #16
Show file File: users_controller.php Project: jackrl/Tsoha-Bootstrap
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['username'], $params['password']);
     if (!$user) {
         View::make('user/login.html', array('error' => 'Wrong username or password!', 'username' => $params['username']));
     } else {
         $_SESSION['user'] = $user->id;
         Redirect::to('/', array('message' => 'Welcome back ' . $user->username . '!'));
     }
 }
Example #17
Show file File: user_controller.php Project: jussiviinikka/Tsoha-Bootstrap
0
 public static function login()
 {
     $params = $_POST;
     $user = User::authenticate($params['email'], $params['password']);
     if (!$user) {
         Redirect::to('/', array('login_error' => 'Wrong email or password'));
     } else {
         $_SESSION['user'] = $user->id;
         Redirect::to('/units', array('message' => 'Welcome ' . $user->first_name . "!"));
     }
 }
Example #18
Show file File: user_controller.php Project: eerojala/Hiihtokilpailujen-tulospalvelu
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['username'], $params['password']);
     if (!$user) {
         $errors = array();
         $errors[] = 'Väärä käyttäjätunnus tai salasana!';
         View::make('user/login.html', array('errors' => $errors, 'username' => $params['username']));
     } else {
         self::login_and_redirect_to_home_page($user);
     }
 }
Example #19
Show file File: user_controller.php Project: KKatriina/Tsoha-Bootstrap
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['nimi'], $params['salasana']);
     if (!$user) {
         View::make('user/login.html', array('message' => "Väärä käyttäjätunnus tai salasana!"));
     } else {
         $_SESSION['user'] = $user->nimi;
         //      self::get_user_logged_in();
         Redirect::to('/user/tervetuloa');
     }
 }
Example #20
Show file File: Login.php Project: nicolaslattuada/minimal-php-mvc
0
 function index()
 {
     if (isset($_POST['login'])) {
         $result = User::authenticate();
         $location = APP_URL . '/admin';
         if ($result) {
             header("Location: {$location}");
         }
     }
     $this->template('content', 'loginForm.phtml');
     $this->show('main.tpl');
 }
Example #21
Show file File: UserTest.php Project: r-hills/live_test
0
 function test_authenticate()
 {
     //Arrange
     $name = "Bob";
     $email = "test@email.com";
     $test_user = new User($name, $email);
     $test_user->save();
     //Act
     $result = User::authenticate($email);
     //Assert
     $this->assertEquals($test_user, $result);
 }
Example #22
Show file File: user.class.php Project: NetOxygen/no2-php-framework
0
 /**
  * user authentication.
  */
 protected function POST_login()
 {
     $user = User::authenticate($_REQUEST['email'], $_REQUEST['cleartext']);
     if (is_null($user)) {
         $this->flash['error'] = t("Bad email or password.");
     } else {
         User::current_is($user);
         $this->flash['success'] = sprintf(t('Welcome back %s!'), h($user->fullname));
         global $router;
         $this->view->redirect_to($router->root_url());
     }
 }
Example #23
Show file File: Login.php Project: tigron/skeleton-package-login
0
 /**
  * Display method
  *
  * @access public
  */
 public function display()
 {
     if (isset($_POST['username']) and isset($_POST['password'])) {
         try {
             $user = \User::authenticate($_POST['username'], $_POST['password']);
             $_SESSION['user'] = $user;
             Session::redirect('/');
         } catch (\Exception $e) {
             Template::get()->assign('error', true);
         }
     }
 }
Example #24
Show file File: user_controller.php Project: rubinju/Todolist
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['username'], $params['password']);
     if (!$user) {
         View::make('user/login.html', array('error' => 'Wrong username or password', 'username' => $params['username']));
     } else {
         $_SESSION['user'] = $user->id;
         //Kint::dump($user);
         Redirect::to('/', array('message' => 'Welcome back ' . $user->username . '. Start by creating a project if you dont have any yet, add tasks after that! The delete task-button is only visible if you click on the task'));
     }
 }
Example #25
Show file File: UserIdentity.php Project: tselishev-semen/Chocolate
0
 public function authenticate()
 {
     $user = new User();
     if ($user->authenticate($this->username, $this->password)) {
         $this->_id = $user->userID;
         $this->setState('employeeID', $user->getEmployeeID());
         $this->setState('fullName', $user->getFullName());
         $this->errorCode = self::ERROR_NONE;
     } else {
         $this->errorCode = self::ERROR_UNKNOWN_IDENTITY;
     }
     return $this->errorCode == self::ERROR_NONE;
 }
Example #26
Show file File: AuthController.php Project: KristianLauttamus/HospitalSchedule
0
 public static function handle_login()
 {
     $params = $_POST;
     $user = User::authenticate($params['email'], $params['password']);
     if (!$user) {
         flash()->error(':(', 'Login failed');
         View::make('login.html', array('email' => $params['email']));
     } else {
         $_SESSION['user'] = $user->id;
         flash('Hey!', 'Nice to see you again');
         Redirect::to('/');
     }
 }
Example #27
Show file File: Default.php Project: novesanchez/project-hangout
0
 public function login($username, $password)
 {
     if ($user = User::authenticate($username, $password)) {
         // user just logged in, update login time.
         $user->lastLogin(time());
         $_SESSION['username'] = $user->username;
         $_SESSION['user_id'] = intval($user->user_id);
         $online = Friend::of($user->user_id);
         return array('r' => 'logged in', 's' => session_id(), 'f' => $online);
     } else {
         return array('r' => 'error', 'e' => 'invalid user');
     }
 }
Example #28
Show file File: Auth.class.php Project: sunitha181288/Signup-and-Login-From-Scratch-Using-PHP
0
 /**
  * Login a user
  *
  * @param string $email     Email address
  * @param string $password  Password
  * @return boolean          true if the new user record was saved successfully, false otherwise
  */
 public function login($email, $password)
 {
     $user = User::authenticate($email, $password);
     if ($user !== null) {
         $this->_currentUser = $user;
         // Store the user ID in the session
         $_SESSION['user_id'] = $user->id;
         // Regenerate the session ID to prevent session hijacking
         session_regenerate_id();
         return true;
     }
     return false;
 }
Example #29
Show file File: Adapter.php Project: laiello/vinhloi
0
 public function authenticate()
 {
     try {
         $this->user = User::authenticate($this->username, $this->password);
         return $this->createResult(Zend_Auth_Result::SUCCESS);
     } catch (Exception $e) {
         if ($e->getMessage() == User::NOT_FOUND) {
             return $this->createResult(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, array(self::NOT_FOUND_MSG));
         }
         if ($e->getMessage() == User::WRONG_PWD) {
             return $this->createResult(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, array(self::BAD_PW_MSG));
         }
     }
 }
Example #30
Show file File: sentinel.php Project: bermi/admin
0
 public function authenticateUsingPostedVars()
 {
     $UserInstance = new User();
     $login = @$this->Controller->params['ak_login'];
     try {
         $result = $UserInstance->authenticate(@$login['login'], @$login['password']);
     } catch (RecordNotFoundException $e) {
         if (!empty($this->Controller->params['ak_login'])) {
             $this->Controller->flash['error'] = $this->t('Invalid user name or password, please try again');
         }
         $this->redirectToSignInScreen();
     }
     return $result;
 }