mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
demo stuff
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -22,4 +22,5 @@ sync.sh
|
|||||||
*.swp
|
*.swp
|
||||||
.debug
|
.debug
|
||||||
.maintenance
|
.maintenance
|
||||||
|
.demo
|
||||||
.htaccess
|
.htaccess
|
||||||
|
|||||||
@@ -923,75 +923,83 @@ class User extends CI_Controller {
|
|||||||
*/
|
*/
|
||||||
function forgot_password() {
|
function forgot_password() {
|
||||||
|
|
||||||
$this->load->helper(array('form', 'url'));
|
if (file_exists('.demo')) {
|
||||||
|
|
||||||
$this->load->library('form_validation');
|
$this->session->set_flashdata('error', __("Password Reset is disabled on the Demo!"));
|
||||||
|
redirect('user/login');
|
||||||
|
|
||||||
$this->form_validation->set_rules('email', 'Email', 'required');
|
} else {
|
||||||
|
|
||||||
|
$this->load->helper(array('form', 'url'));
|
||||||
|
|
||||||
if ($this->form_validation->run() == FALSE)
|
$this->load->library('form_validation');
|
||||||
{
|
|
||||||
$data['page_title'] = __("Forgot Password");
|
|
||||||
$this->load->view('interface_assets/mini_header', $data);
|
|
||||||
$this->load->view('user/forgot_password');
|
|
||||||
$this->load->view('interface_assets/footer');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Check email address exists
|
|
||||||
$this->load->model('user_model');
|
|
||||||
|
|
||||||
$check_email = $this->user_model->check_email_address($this->input->post('email', true));
|
$this->form_validation->set_rules('email', 'Email', 'required');
|
||||||
|
|
||||||
if($check_email == TRUE) {
|
if ($this->form_validation->run() == FALSE)
|
||||||
// Generate password reset code 50 characters long
|
{
|
||||||
$this->load->helper('string');
|
$data['page_title'] = __("Forgot Password");
|
||||||
$reset_code = random_string('alnum', 50);
|
$this->load->view('interface_assets/mini_header', $data);
|
||||||
|
$this->load->view('user/forgot_password');
|
||||||
|
$this->load->view('interface_assets/footer');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check email address exists
|
||||||
|
$this->load->model('user_model');
|
||||||
|
|
||||||
$this->user_model->set_password_reset_code($this->input->post('email', true), $reset_code);
|
$check_email = $this->user_model->check_email_address($this->input->post('email', true));
|
||||||
|
|
||||||
// Send email with reset code
|
if($check_email == TRUE) {
|
||||||
|
// Generate password reset code 50 characters long
|
||||||
|
$this->load->helper('string');
|
||||||
|
$reset_code = random_string('alnum', 50);
|
||||||
|
|
||||||
$this->data['reset_code'] = $reset_code;
|
$this->user_model->set_password_reset_code($this->input->post('email', true), $reset_code);
|
||||||
$this->load->library('email');
|
|
||||||
|
|
||||||
if($this->optionslib->get_option('emailProtocol') == "smtp") {
|
// Send email with reset code
|
||||||
$config = Array(
|
|
||||||
'protocol' => $this->optionslib->get_option('emailProtocol'),
|
|
||||||
'smtp_crypto' => $this->optionslib->get_option('smtpEncryption'),
|
|
||||||
'smtp_host' => $this->optionslib->get_option('smtpHost'),
|
|
||||||
'smtp_port' => $this->optionslib->get_option('smtpPort'),
|
|
||||||
'smtp_user' => $this->optionslib->get_option('smtpUsername'),
|
|
||||||
'smtp_pass' => $this->optionslib->get_option('smtpPassword'),
|
|
||||||
'crlf' => "\r\n",
|
|
||||||
'newline' => "\r\n"
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->email->initialize($config);
|
$this->data['reset_code'] = $reset_code;
|
||||||
}
|
$this->load->library('email');
|
||||||
|
|
||||||
$message = $this->load->view('email/forgot_password', $this->data, TRUE);
|
if($this->optionslib->get_option('emailProtocol') == "smtp") {
|
||||||
|
$config = Array(
|
||||||
|
'protocol' => $this->optionslib->get_option('emailProtocol'),
|
||||||
|
'smtp_crypto' => $this->optionslib->get_option('smtpEncryption'),
|
||||||
|
'smtp_host' => $this->optionslib->get_option('smtpHost'),
|
||||||
|
'smtp_port' => $this->optionslib->get_option('smtpPort'),
|
||||||
|
'smtp_user' => $this->optionslib->get_option('smtpUsername'),
|
||||||
|
'smtp_pass' => $this->optionslib->get_option('smtpPassword'),
|
||||||
|
'crlf' => "\r\n",
|
||||||
|
'newline' => "\r\n"
|
||||||
|
);
|
||||||
|
|
||||||
$this->email->from($this->optionslib->get_option('emailAddress'), $this->optionslib->get_option('emailSenderName'));
|
$this->email->initialize($config);
|
||||||
$this->email->to($this->input->post('email', true));
|
}
|
||||||
|
|
||||||
$this->email->subject('Wavelog Account Password Reset');
|
$message = $this->load->view('email/forgot_password', $this->data, TRUE);
|
||||||
$this->email->message($message);
|
|
||||||
|
|
||||||
if (! $this->email->send())
|
$this->email->from($this->optionslib->get_option('emailAddress'), $this->optionslib->get_option('emailSenderName'));
|
||||||
{
|
$this->email->to($this->input->post('email', true));
|
||||||
// Redirect to login page with message
|
|
||||||
$this->session->set_flashdata('warning', __("Email settings are incorrect."));
|
$this->email->subject('Wavelog Account Password Reset');
|
||||||
redirect('user/login');
|
$this->email->message($message);
|
||||||
|
|
||||||
|
if (! $this->email->send())
|
||||||
|
{
|
||||||
|
// Redirect to login page with message
|
||||||
|
$this->session->set_flashdata('warning', __("Email settings are incorrect."));
|
||||||
|
redirect('user/login');
|
||||||
|
} else {
|
||||||
|
// Redirect to login page with message
|
||||||
|
$this->session->set_flashdata('notice', __("Password Reset Processed."));
|
||||||
|
redirect('user/login');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Redirect to login page with message
|
// No account found just return to login page
|
||||||
$this->session->set_flashdata('notice', __("Password Reset Processed."));
|
$this->session->set_flashdata('notice', __("Password Reset Processed."));
|
||||||
redirect('user/login');
|
redirect('user/login');
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// No account found just return to login page
|
|
||||||
$this->session->set_flashdata('notice', __("Password Reset Processed."));
|
|
||||||
redirect('user/login');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,16 +38,26 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
<div class="my-2 rounded-0 shadow-sm card mb-2 shadow-sm">
|
<div class="my-2 rounded-0 shadow-sm card mb-2 shadow-sm">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
<?php // only used for Wavelog Demo
|
||||||
|
if (file_exists('.demo')) { ?>
|
||||||
|
<div class="border-bottom mb-3">
|
||||||
|
<h5><?= __("Welcome to the Demo of Wavelog"); ?></h5>
|
||||||
|
<p><?= __("This demo will be reset every night at 0200z."); ?><br><br>
|
||||||
|
<?= __("Username"); ?>: demo<br>
|
||||||
|
<?= __("Password"); ?>: demo<br><br>
|
||||||
|
<?= sprintf(__("More Information about Wavelog on <a href='%s' target='_blank'>Github</a>."), "https://www.github.com/wavelog/wavelog"); ?></p>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<form method="post" action="<?php echo site_url('user/login'); ?>" name="users">
|
<form method="post" action="<?php echo site_url('user/login'); ?>" name="users">
|
||||||
<?php $this->form_validation->set_error_delimiters('', ''); ?>
|
<?php $this->form_validation->set_error_delimiters('', ''); ?>
|
||||||
<input type="hidden" name="id" value="<?php echo $this->uri->segment(3); ?>" />
|
<input type="hidden" name="id" value="<?php echo $this->uri->segment(3); ?>" />
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label for="floatingInput"><strong><?= __("Username"); ?></strong></label>
|
<label for="floatingInput"><strong><?= __("Username"); ?></strong></label>
|
||||||
<input type="text" name="user_name" class="form-control" id="floatingInput" placeholder="<?= __("Username"); ?>" value="<?php echo $this->input->post('user_name'); ?>" autofocus>
|
<input type="text" name="user_name" class="form-control" id="floatingInput" placeholder="<?php if (file_exists('.demo')) { echo "demo"; } else { echo __("Username"); } ?>" value="<?php echo $this->input->post('user_name'); ?>" autofocus>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label for="floatingPassword"><strong><?= __("Password"); ?></strong></label>
|
<label for="floatingPassword"><strong><?= __("Password"); ?></strong></label>
|
||||||
<input type="password" name="user_password" class="form-control" id="floatingPassword" placeholder="<?= __("Password"); ?>">
|
<input type="password" name="user_password" class="form-control" id="floatingPassword" placeholder="<?php if (file_exists('.demo')) { echo "demo"; } else { echo __("Password"); } ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
Reference in New Issue
Block a user