Adding user creation with club memebership

This commit is contained in:
HadleySo
2026-02-18 21:46:44 -06:00
parent 44c70816f3
commit 8027474f2d
4 changed files with 128 additions and 3 deletions

View File

@@ -43,10 +43,33 @@ class Header_auth extends CI_Controller
// Look up user by the header value
$query = $this->user_model->get($username);
if (!$query || $query->num_rows() !== 1) {
$this->session->set_flashdata('error', __('User not found.'));
redirect('user/login');
// Config check if create user
if ($this->config->item('auth_header_create')) {
$this->load->model('user_model');
$club_id = $this->config->item('auth_header_club_id');
$result = $this->user_model->add_minimal(username: $username, club_id: $club_id);
switch ($result) {
case EUSERNAMEEXISTS:
$data['username_error'] = sprintf(__("Username %s already in use!"), '<b>' . $this->input->post('user_name') . '</b>');
break;
case EEMAILEXISTS:
$data['email_error'] = sprintf(__("E-mail %s already in use!"), '<b>' . $this->input->post('user_email') . '</b>');
break;
case EPASSWORDINVALID:
$data['password_error'] = __("Invalid Password!");
break;
case OK:
redirect('header_auth/login');
return;
}
} else {
$this->session->set_flashdata('error', __('User not found.'));
redirect('user/login');
}
}
$user = $query->row();
@@ -75,6 +98,28 @@ class Header_auth extends CI_Controller
];
$this->input->set_cookie($cookie);
$this->load->model('user_model');
// Get full user record
$user = $this->user_model->get($username)->row();
// Critical: Update session data
$this->user_model->update_session($user->user_id);
$this->user_model->set_last_seen($user->user_id);
// Set essential session data
$this->session->set_userdata(array(
'user_id' => $user->user_id,
'user_name' => $user->user_name,
'user_type' => $user->user_type,
'user_stylesheet' => $user->user_stylesheet ?? 'bootstrap',
'user_column1' => $user->user_column1 ?? 'Mode',
'user_column2' => $user->user_column2 ?? 'RSTS',
'user_column3' => $user->user_column3 ?? 'RSTR',
'user_column4' => $user->user_column4 ?? 'Band',
'user_column5' => $user->user_column5 ?? 'Country',
// Add other preferences as needed
));
log_message('info', "User ID [{$user->user_id}] logged in via header auth.");
redirect('dashboard');
}