Skip to content

Commit

Permalink
Merge pull request #524 from getgrav/feature/show-account-page-for-lo…
Browse files Browse the repository at this point in the history
…gin-acl

Show account page for users with admin.login ACL
  • Loading branch information
flaviocopes authored and rhukster committed Apr 27, 2016
1 parent a8fd34c commit 33e363a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions classes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ public function data($type, array $post = [])
$obj = User::load(preg_replace('|users/|', '', $type));
$obj->merge($post);

$data[$type] = $obj;
} elseif (preg_match('|user/|', $type)) {
$obj = User::load(preg_replace('|user/|', '', $type));
$obj->merge($post);

$data[$type] = $obj;
} elseif (preg_match('|config/|', $type)) {
$type = preg_replace('|config/|', '', $type);
Expand Down
7 changes: 4 additions & 3 deletions classes/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1580,14 +1580,16 @@ public function taskSave()
*/
public function taskContinue()
{
$data = (array) $this->data;

if ($this->view == 'users') {
$this->setRedirect("{$this->view}/{$this->post['username']}");
$this->setRedirect("{$this->view}/{$data['username']}");

return true;
}

if ($this->view == 'groups') {
$this->setRedirect("{$this->view}/{$this->post['groupname']}");
$this->setRedirect("{$this->view}/{$data['groupname']}");

return true;
}
Expand All @@ -1596,7 +1598,6 @@ public function taskContinue()
return false;
}

$data = (array) $this->data;
$route = $data['route'] != '/' ? $data['route'] : '';
$folder = ltrim($data['folder'], '_');
if (!empty($data['modular'])) {
Expand Down
3 changes: 2 additions & 1 deletion pages/admin/users.md → pages/admin/user.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
title: Users
title: User

access:
admin.users: true
admin.login: true
admin.super: true
---
2 changes: 1 addition & 1 deletion themes/grav/templates/partials/nav.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{#{% if admin.authorize %}#}
<div id="admin-user-details">
<a href="{{ base_url_relative }}/users/{{ admin.user.username|e }}">
<a href="{{ base_url_relative }}/user/{{ admin.user.username|e }}">
<img src="https://www.gravatar.com/avatar/{{ admin.user.email|md5 }}?s=48" />

<div class="admin-user-names">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
{% if admin.route %}
{% set user = admin.data('users/' ~ admin.route) %}
{% set title = "PLUGIN_ADMIN.USER"|tu ~ ": " ~ admin.route|e %}

{% else %}
{% set title = "PLUGIN_ADMIN.USERS"|tu %}
{% endif %}


{% block titlebar %}
{% if not admin.route %}
<div class="button-bar">
Expand Down

0 comments on commit 33e363a

Please sign in to comment.