mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 03:26:20 +05:30
Change password page
This commit is contained in:
parent
cb39378b5a
commit
92a13ece06
3 changed files with 78 additions and 2 deletions
25
system/admin/views/edit-password.html.php
Normal file
25
system/admin/views/edit-password.html.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<?php
|
||||
if (isset($_SESSION[site_url()]['user'])) {
|
||||
$user = $_SESSION[site_url()]['user'];
|
||||
}
|
||||
?>
|
||||
<h2><?php echo i18n('change_password'); echo ': ' . $user; ?></h2>
|
||||
<br>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
|
||||
<div class="form-group row">
|
||||
<label for="site.url" class="col-sm-2 col-form-label"><?php echo i18n('Username');?></label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" name="username" readonly class="form-control" id="username-id" value="<?php echo $user;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="site.url" class="col-sm-2 col-form-label"><?php echo i18n('Password');?></label>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" name="password" class="form-control" id="password" value="" placeholder="<?php echo i18n('change_password');?>">
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" class="btn btn-primary" style="width:100px;" value="<?php echo i18n('Save');?>">
|
||||
<span><a class="btn btn-primary" href="<?php echo site_url();?>admin"><?php echo i18n('Cancel');?></a></span>
|
||||
</form>
|
||||
|
|
@ -230,6 +230,13 @@ if (isset($_GET['search'])) {
|
|||
</p>
|
||||
</a>
|
||||
<ul class="nav nav-treeview">
|
||||
<li class="nav-item">
|
||||
<a href="<?php echo site_url();?>edit/password" class="nav-link">
|
||||
<p>
|
||||
<?php echo i18n('Change_password');?>
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="<?php echo site_url();?>edit/profile" class="nav-link">
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -288,9 +288,7 @@ get('/author/:name/feed', function ($name) {
|
|||
|
||||
// Edit the profile
|
||||
get('/edit/profile', function () {
|
||||
|
||||
if (login()) {
|
||||
|
||||
config('views.root', 'system/admin/views');
|
||||
render('edit-page', array(
|
||||
'title' => generate_title('is_default', i18n('Edit_profile')),
|
||||
|
|
@ -350,6 +348,52 @@ post('/edit/profile', function () {
|
|||
}
|
||||
});
|
||||
|
||||
get('/edit/password', function () {
|
||||
if (login()) {
|
||||
config('views.root', 'system/admin/views');
|
||||
render('edit-password', array(
|
||||
'title' => generate_title('is_default', i18n('change_password')),
|
||||
'description' => safe_html(strip_tags(blog_description())),
|
||||
'canonical' => site_url(),
|
||||
'metatags' => generate_meta(null, null),
|
||||
'type' => 'is_profile',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'edit-password',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » '. i18n('change_password'),
|
||||
));
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
});
|
||||
|
||||
post('/edit/password', function() {
|
||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||
if (login() && $proper) {
|
||||
$username = from($_REQUEST, 'username');
|
||||
$new_password = from($_REQUEST, 'password');
|
||||
$user = $_SESSION[site_url()]['user'];
|
||||
$role = user('role', $user);
|
||||
$old_password = user('password', $username);
|
||||
if ($user === $username) {
|
||||
$file = 'config/users/' . $user . '.ini';
|
||||
if (file_exists($file)) {
|
||||
if (!empty($new_password)) {
|
||||
update_user($user, $new_password, $role);
|
||||
}
|
||||
}
|
||||
$redir = site_url() . 'admin';
|
||||
header("location: $redir");
|
||||
} else {
|
||||
$redir = site_url();
|
||||
header("location: $redir");
|
||||
}
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
});
|
||||
|
||||
// Edit the frontpage
|
||||
get('/edit/frontpage', function () {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue