mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-06 10:49:20 +02:00
- add installGateway to app config - update route names and groups - remove `author_name` and `author_email` from `episodes` table - remove `author_name` and `author_email` from `podcasts` table - remove `owner_id` + add `created_by` and `updated_by` fields in `podcasts` and `episodes` tables - remove unnecessary comments in database fields - remove confirm password inputs from auth forms for better ux - rename `pub_date` field to `published_at` and add publication time field in episode form closes #14, #28
75 lines
1.8 KiB
PHP
75 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use Config\Services;
|
|
use App\Models\UserModel;
|
|
|
|
class Myaccount extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
return view('admin/my_account/view');
|
|
}
|
|
|
|
public function changePassword()
|
|
{
|
|
helper('form');
|
|
|
|
return view('admin/my_account/change_password');
|
|
}
|
|
|
|
public function attemptChange()
|
|
{
|
|
$auth = Services::authentication();
|
|
$userModel = new UserModel();
|
|
|
|
// Validate here first, since some things,
|
|
// like the password, can only be validated properly here.
|
|
$rules = [
|
|
'password' => 'required',
|
|
'new_password' => 'required|strong_password|differs[password]',
|
|
];
|
|
|
|
if (!$this->validate($rules)) {
|
|
return redirect()
|
|
->back()
|
|
->withInput()
|
|
->with('errors', $userModel->errors());
|
|
}
|
|
|
|
$credentials = [
|
|
'email' => user()->email,
|
|
'password' => $this->request->getPost('password'),
|
|
];
|
|
|
|
if (!$auth->validate($credentials)) {
|
|
return redirect()
|
|
->back()
|
|
->withInput()
|
|
->with('error', lang('MyAccount.messages.wrongPasswordError'));
|
|
}
|
|
|
|
user()->password = $this->request->getPost('new_password');
|
|
$userModel->save(user());
|
|
|
|
if (!$userModel->save(user())) {
|
|
return redirect()
|
|
->back()
|
|
->withInput()
|
|
->with('errors', $userModel->errors());
|
|
}
|
|
|
|
// Success!
|
|
return redirect()
|
|
->back()
|
|
->with('message', lang('MyAccount.messages.passwordChangeSuccess'));
|
|
}
|
|
}
|