mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
refactoring
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
class User extends CI_Controller {
|
||||
|
||||
private $pwd_placeholder = '**********';
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('user_model');
|
||||
@@ -396,7 +398,6 @@ class User extends CI_Controller {
|
||||
$query = $this->user_model->get_by_id($this->uri->segment(3));
|
||||
|
||||
$data['existing_languages'] = $this->config->item('languages');
|
||||
$pwd_placeholder = '**********';
|
||||
|
||||
$this->load->model('bands');
|
||||
$this->load->library('form_validation');
|
||||
@@ -440,6 +441,17 @@ class User extends CI_Controller {
|
||||
// Max value to be present in the "QSO page last QSO count" selectbox
|
||||
$data['qso_page_last_qso_count_limit'] = QSO_PAGE_QSOS_COUNT_LIMIT;
|
||||
|
||||
// SSO / OIDC cases
|
||||
$data['external_account'] = !empty($query->row()->external_account);
|
||||
$data['auth_header_enable'] = $this->config->item('auth_header_enable') ?? false;
|
||||
if ($data['auth_header_enable']) {
|
||||
// expecting sso.php in the config folder
|
||||
$this->config->load('sso', true, true);
|
||||
}
|
||||
$data['auth_header_allow_direct_login'] = $this->config->item('auth_header_allow_direct_login', 'sso') ?? true;
|
||||
$data['auth_header_hide_password_field'] = $this->config->item('auth_header_hide_password_field', 'sso') ?? false;
|
||||
$data['sso_claim_config'] = $this->config->item('auth_headers_claim_config', 'sso') ?: [];
|
||||
|
||||
$data['page_title'] = __("Edit User");
|
||||
|
||||
if ($this->form_validation->run() == FALSE)
|
||||
@@ -465,7 +477,7 @@ class User extends CI_Controller {
|
||||
$data['user_password'] = $this->input->post('user_password',true);
|
||||
} else {
|
||||
if ($q->user_password !== '' && $q->user_password !== null) {
|
||||
$data['user_password'] = $pwd_placeholder;
|
||||
$data['user_password'] = $this->pwd_placeholder;
|
||||
} else {
|
||||
$data['user_password'] = '';
|
||||
}
|
||||
@@ -535,7 +547,7 @@ class User extends CI_Controller {
|
||||
$data['user_clublog_password'] = $this->input->post('user_clublog_password', true);
|
||||
} else {
|
||||
if ($q->user_clublog_password !== '' && $q->user_clublog_password !== null) {
|
||||
$data['user_clublog_password'] = $pwd_placeholder;
|
||||
$data['user_clublog_password'] = $this->pwd_placeholder;
|
||||
} else {
|
||||
$data['user_clublog_password'] = '';
|
||||
}
|
||||
@@ -545,7 +557,7 @@ class User extends CI_Controller {
|
||||
$data['user_lotw_password'] = $this->input->post('user_lotw_password', true);
|
||||
} else {
|
||||
if ($q->user_lotw_password !== '' && $q->user_lotw_password !== null) {
|
||||
$data['user_lotw_password'] = $pwd_placeholder;
|
||||
$data['user_lotw_password'] = $this->pwd_placeholder;
|
||||
} else {
|
||||
$data['user_lotw_password'] = '';
|
||||
}
|
||||
@@ -561,7 +573,7 @@ class User extends CI_Controller {
|
||||
$data['user_eqsl_password'] = $this->input->post('user_eqsl_password', true);
|
||||
} else {
|
||||
if ($q->user_eqsl_password !== '' && $q->user_eqsl_password !== null) {
|
||||
$data['user_eqsl_password'] = $pwd_placeholder;
|
||||
$data['user_eqsl_password'] = $this->pwd_placeholder;
|
||||
} else {
|
||||
$data['user_eqsl_password'] = '';
|
||||
}
|
||||
@@ -953,7 +965,17 @@ class User extends CI_Controller {
|
||||
}
|
||||
|
||||
unset($data);
|
||||
switch($this->user_model->edit($this->input->post())) {
|
||||
|
||||
// SSO / OIDC: Override submitted values for fields managed by the IdP
|
||||
$post_data = $this->input->post();
|
||||
if (!empty($query->row()->external_account)) {
|
||||
$post_data['user_name'] = $query->row()->user_name;
|
||||
if (!($this->config->item('auth_header_allow_direct_login') ?? true)) {
|
||||
$post_data['user_password'] = $this->pwd_placeholder; // placeholder → model skips password update
|
||||
}
|
||||
}
|
||||
|
||||
switch($this->user_model->edit($post_data)) {
|
||||
// Check for errors
|
||||
case EUSERNAMEEXISTS:
|
||||
$data['username_error'] = 'Username <b>'.$this->input->post('user_name', true).'</b> already in use!';
|
||||
@@ -1243,9 +1265,15 @@ class User extends CI_Controller {
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data['page_title'] = __("Login");
|
||||
$data['https_check'] = $this->https_check();
|
||||
|
||||
$data['auth_header_enable'] = $this->config->item('auth_header_enable') ?? false;
|
||||
$data['auth_header_text'] = $this->config->item('auth_header_text') ?: '';
|
||||
$data['hide_login_form'] = ($data['auth_header_enable'] && !($this->config->item('auth_allow_direct_login') ?? true));
|
||||
if ($data['auth_header_enable']) {
|
||||
// expecting sso.php in the config folder
|
||||
$this->config->load('sso', true, true);
|
||||
}
|
||||
$data['auth_header_text'] = $this->config->item('auth_header_text', 'sso') ?: '';
|
||||
$data['hide_login_form'] = ($data['auth_header_enable'] && !($this->config->item('auth_header_allow_direct_login', 'sso') ?? true));
|
||||
|
||||
$this->load->view('interface_assets/mini_header', $data);
|
||||
$this->load->view('user/login');
|
||||
$this->load->view('interface_assets/footer');
|
||||
@@ -1320,9 +1348,12 @@ class User extends CI_Controller {
|
||||
$this->input->set_cookie('tmp_msg', json_encode(['notice', sprintf(__("User %s logged out."), $user_name)]), 10, '');
|
||||
}
|
||||
|
||||
$logout = $this->config->item('auth_url_logout');
|
||||
if ($this->config->item('auth_header_enable') && $logout !== null && $logout !== '') {
|
||||
redirect($logout);
|
||||
if ($this->config->item('auth_header_enable')) {
|
||||
$this->config->load('sso', true, true);
|
||||
$logout = $this->config->item('auth_header_url_logout', 'sso') ?: null;
|
||||
if ($logout !== null) {
|
||||
redirect($logout);
|
||||
}
|
||||
}
|
||||
|
||||
redirect('user/login');
|
||||
|
||||
Reference in New Issue
Block a user