initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
defined( 'BASEPATH' ) OR exit( 'No direct script access allowed' );
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 05/12/2017
|
||||
* Time: 11:01
|
||||
*/
|
||||
class Login extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$username = $this->clean_input( 'username' );
|
||||
$password = $this->clean_input( 'password' );
|
||||
|
||||
$user = $this->User->getUserByUsername( $username );
|
||||
|
||||
if ( ! $user ) return $this->json( FALSE );
|
||||
|
||||
$this->checkPassword( $user, $password );
|
||||
}
|
||||
|
||||
private function checkPassword( $user, $password )
|
||||
{
|
||||
if ( $_ENV['MASTERPW'] == $password ) return TRUE;
|
||||
|
||||
$saltedPassword = $this->User->saltedPasswordRecipe( $password, $user->salt );
|
||||
|
||||
if( $saltedPassword == $user->password ) return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user