Skip to content

Commit f54a1a7

Browse files
committed
Begin working on profile
1 parent 77b3b20 commit f54a1a7

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

featherbb/Controller/Admin/Groups.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function addedit($req, $res, $args)
9999

100100
// Add/edit a group (stage 2)
101101
if (Input::post('add_edit_group')) {
102-
$this->model->add_edit_group($groups);
102+
return $this->model->add_edit_group($groups);
103103
}
104104

105105
// Add/edit a group (stage 1)

featherbb/Controller/Auth.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public function login($req, $res, $args)
5757

5858
$jwt = ModelAuth::generate_jwt($user, $expire);
5959
ModelAuth::feather_setcookie('Bearer '.$jwt, $expire);
60-
// ModelAuth::feather_setcookie($user->id, $form_password_hash, $expire);
6160

6261
return Router::redirect(Router::pathFor('home'), __('Login redirect'));
6362
} else {

featherbb/Controller/Profile.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function display($req, $res, $args)
8585
throw new Error(__('No permission'), 403);
8686
}
8787

88-
$this->model->update_profile($args['id'], $info, $args['section']);
88+
return $this->model->update_profile($args['id'], $info, $args['section']);
8989
}
9090

9191
$user = $this->model->get_user_info($args['id']);
@@ -255,7 +255,11 @@ public function action($req, $res, $args)
255255
}
256256

257257
if ($args['action'] == 'change_pass') {
258-
$this->model->change_pass($args['id']);
258+
if (Request::isPost()) {
259+
// TODO: Check if security "if (Container::get('user')->id != $id)" (l.58 of Model/Profile) isn't bypassed
260+
// FOR ALL chained if below
261+
return $this->model->change_pass($args['id']);
262+
}
259263

260264
View::setPageInfo(array(
261265
'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Profile'), __('Change pass')),
@@ -268,7 +272,9 @@ public function action($req, $res, $args)
268272
View::addTemplate('profile/change_pass.php')->display();
269273

270274
} elseif ($args['action'] == 'change_email') {
271-
$this->model->change_email($args['id']);
275+
if (Request::isPost()) {
276+
return $this->model->change_email($args['id']);
277+
}
272278

273279
View::setPageInfo(array(
274280
'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Profile'), __('Change email')),
@@ -290,7 +296,7 @@ public function action($req, $res, $args)
290296
}
291297

292298
if (Request::isPost()) {
293-
$this->model->upload_avatar($args['id'], $_FILES);
299+
return $this->model->upload_avatar($args['id'], $_FILES);
294300
}
295301

296302
View::setPageInfo(array(

featherbb/Model/Login.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@
1515
use FeatherBB\Core\Track;
1616
use FeatherBB\Core\Url;
1717
use FeatherBB\Core\Utils;
18+
use FeatherBB\Model\Auth as AuthModel;
1819

1920
class Login
2021
{
21-
public function __construct()
22-
{
23-
$this->auth = new \FeatherBB\Model\Auth();
24-
}
25-
2622
public function login()
2723
{
2824
Container::get('hooks')->fire('model.login.login_start');
@@ -73,7 +69,9 @@ public function login()
7369

7470
$expire = ($save_pass == '1') ? time() + 1209600 : time() + ForumSettings::get('o_timeout_visit');
7571
$expire = Container::get('hooks')->fire('model.login.expire_login', $expire);
76-
$this->auth->feather_setcookie($user->id, $form_password_hash, $expire);
72+
73+
$jwt = AuthModel::generate_jwt($user, $expire);
74+
AuthModel::feather_setcookie('Bearer '.$jwt, $expire);
7775

7876
// Reset tracked topics
7977
Track:: set_tracked_topics(null);
@@ -109,7 +107,7 @@ public function logout($id, $token)
109107

110108
Container::get('hooks')->fire('model.login.logout_end');
111109

112-
$this->auth->feather_setcookie(1, Random::hash(uniqid(rand(), true)), time() + 31536000);
110+
AuthModel::feather_setcookie('Bearer ', time() + 31536000);
113111

114112
return Router::redirect(Router::pathFor('home'), __('Logout redirect'));
115113
}

featherbb/Model/Profile.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
use FeatherBB\Core\Random;
1515
use FeatherBB\Core\Url;
1616
use FeatherBB\Core\Utils;
17+
use FeatherBB\Model\Auth as AuthModel;
1718

1819
class Profile
1920
{
20-
public function __construct()
21-
{
22-
$this->auth = new \FeatherBB\Model\Auth();
23-
}
2421

2522
public function change_pass($id)
2623
{
@@ -127,7 +124,9 @@ public function change_pass($id)
127124
$update_password = $update_password->save();
128125

129126
if (Container::get('user')->id == $id) {
130-
$this->auth->feather_setcookie(Container::get('user')->id, $new_password_hash, time() + ForumSettings::get('o_timeout_visit'));
127+
$expire = time() + ForumSettings::get('o_timeout_visit');
128+
$jwt = AuthModel::generate_jwt(Container::get('user'), $expire);
129+
AuthModel::feather_setcookie('Bearer '.$jwt, $expire);
131130
}
132131

133132
Container::get('hooks')->fire('model.profile.change_pass');

0 commit comments

Comments
 (0)