Revert "an attempt at something"
This reverts commit 20d7d4b9b627ce51d5312b5d0fbdf3b21207565c.
This commit is contained in:
parent
031dd79c56
commit
c484c1e737
6 changed files with 39 additions and 55 deletions
|
@ -124,7 +124,7 @@ class AuthController extends Controller
|
||||||
return Template::render('global/information');
|
return Template::render('global/information');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->passwordExpired()) {
|
if (strlen($user->password) < 1) {
|
||||||
$message = 'Your password expired.';
|
$message = 'Your password expired.';
|
||||||
$redirect = Router::route('auth.resetpassword');
|
$redirect = Router::route('auth.resetpassword');
|
||||||
Template::vars(compact('message', 'redirect'));
|
Template::vars(compact('message', 'redirect'));
|
||||||
|
@ -132,7 +132,7 @@ class AuthController extends Controller
|
||||||
return Template::render('global/information');
|
return Template::render('global/information');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user->verifyPassword($password)) {
|
if (!password_verify($password, $user->password)) {
|
||||||
$this->touchRateLimit($user->id);
|
$this->touchRateLimit($user->id);
|
||||||
$message = 'The password you entered was invalid.';
|
$message = 'The password you entered was invalid.';
|
||||||
Template::vars(compact('message', 'redirect'));
|
Template::vars(compact('message', 'redirect'));
|
||||||
|
@ -552,7 +552,16 @@ class AuthController extends Controller
|
||||||
return Template::render('global/information');
|
return Template::render('global/information');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->setPassword($password);
|
// Hash the password
|
||||||
|
$password = password_hash($password, PASSWORD_BCRYPT);
|
||||||
|
|
||||||
|
// Update the user
|
||||||
|
DB::table('users')
|
||||||
|
->where('user_id', $user->id)
|
||||||
|
->update([
|
||||||
|
'password' => $password,
|
||||||
|
'password_chan' => time(),
|
||||||
|
]);
|
||||||
|
|
||||||
$message = "Changed your password! You may now log in.";
|
$message = "Changed your password! You may now log in.";
|
||||||
$redirect = Router::route('auth.login');
|
$redirect = Router::route('auth.login');
|
||||||
|
|
|
@ -12,7 +12,6 @@ use Sakura\DB;
|
||||||
use Sakura\News\Category;
|
use Sakura\News\Category;
|
||||||
use Sakura\Template;
|
use Sakura\Template;
|
||||||
use Sakura\User;
|
use Sakura\User;
|
||||||
use Sakura\UserTest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta page controllers (sections that aren't big enough to warrant a dedicated controller).
|
* Meta page controllers (sections that aren't big enough to warrant a dedicated controller).
|
||||||
|
@ -29,10 +28,6 @@ class MetaController extends Controller
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$test = new UserTest(1);
|
|
||||||
|
|
||||||
echo $test->country(true);
|
|
||||||
|
|
||||||
// Get the newest user
|
// Get the newest user
|
||||||
$newestUserId = DB::table('users')
|
$newestUserId = DB::table('users')
|
||||||
->whereNotIn('rank_main', [config('rank.banned'), config('rank.inactive')])
|
->whereNotIn('rank_main', [config('rank.banned'), config('rank.inactive')])
|
||||||
|
|
|
@ -114,7 +114,7 @@ class AdvancedController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check password
|
// Check password
|
||||||
if (!ActiveUser::$user->passwordVerify($password)) {
|
if (!password_verify($password, ActiveUser::$user->password)) {
|
||||||
$message = "Your password was invalid!";
|
$message = "Your password was invalid!";
|
||||||
Template::vars(compact('redirect', 'message'));
|
Template::vars(compact('redirect', 'message'));
|
||||||
return Template::render('global/information');
|
return Template::render('global/information');
|
||||||
|
|
|
@ -36,15 +36,15 @@ class Notification
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$data = $data[0];
|
$data = $data[0];
|
||||||
|
|
||||||
$this->id = intval($data->alert_id);
|
$this->id = $data->alert_id;
|
||||||
$this->user = intval($data->user_id);
|
$this->user = $data->user_id;
|
||||||
$this->time = intval($data->alert_timestamp);
|
$this->time = $data->alert_timestamp;
|
||||||
$this->read = intval($data->alert_read) !== 0;
|
$this->read = intval($data->alert_read) !== 0;
|
||||||
$this->title = $data->alert_title;
|
$this->title = $data->alert_title;
|
||||||
$this->text = $data->alert_text;
|
$this->text = $data->alert_text;
|
||||||
$this->link = $data->alert_link;
|
$this->link = $data->alert_link;
|
||||||
$this->image = $data->alert_img;
|
$this->image = $data->alert_img;
|
||||||
$this->timeout = intval($data->alert_timeout);
|
$this->timeout = $data->alert_timeout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
45
app/User.php
45
app/User.php
|
@ -45,7 +45,28 @@ class User
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $password = '';
|
public $passwordHash = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user's password salt.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $passwordSalt = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user's password algorithm.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $passwordAlgo = 'disabled';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The password iterations.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $passwordIter = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UNIX timestamp of last time the password was changed.
|
* UNIX timestamp of last time the password was changed.
|
||||||
|
@ -1098,28 +1119,6 @@ class User
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if password expired
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function passwordExpired()
|
|
||||||
{
|
|
||||||
return strlen($this->password) < 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify the user's password
|
|
||||||
*
|
|
||||||
* @param string $password
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function verifyPassword($password)
|
|
||||||
{
|
|
||||||
return password_verify($password, $this->password);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the notifications for this user.
|
* Get all the notifications for this user.
|
||||||
*
|
*
|
||||||
|
|
19
utility.php
19
utility.php
|
@ -41,25 +41,6 @@ function view($name, $vars = [])
|
||||||
return Template::render($name);
|
return Template::render($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert camel case to snake case
|
|
||||||
function camel_to_snake($text)
|
|
||||||
{
|
|
||||||
return ltrim(strtolower(preg_replace('#[A-Z]#', '_$0', $text)), '_');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert snake case to camel case
|
|
||||||
function snake_to_camel($text)
|
|
||||||
{
|
|
||||||
$split = explode('_', $text);
|
|
||||||
$name = array_shift($split);
|
|
||||||
|
|
||||||
foreach ($split as $part) {
|
|
||||||
$name .= ucfirst($part);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
function clean_string($string, $lower = false, $noSpecial = false, $replaceSpecial = '')
|
function clean_string($string, $lower = false, $noSpecial = false, $replaceSpecial = '')
|
||||||
{
|
{
|
||||||
// Run common sanitisation function over string
|
// Run common sanitisation function over string
|
||||||
|
|
Reference in a new issue