Skip to content

Commit 12ddf85

Browse files
committed
Remove the root sprinkle
1 parent 584039a commit 12ddf85

7 files changed

Lines changed: 35 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Refactor error handling. Move responsibility for displayErrorDetails to handlers, and factor our ErrorRenderers. Addresses (#702)
77
- Move `composer.json` to root directory to allow installing UF via composer create-project
88
- Move `sprinkles.json` to app directory to make it easier to find
9+
- Eliminate the `root` theme Sprinkle. Custom styling for the root user is now handled with some Twig logic in the `admin` Sprinkle (#726)
910
- Rename bundle.config.json -> asset-bundles.json (#726)
1011
- Factor out "system" classes from core Sprinkle
1112
- Refactor overall application lifecycle; move main lifecycle into UserFrosting\System\UserFrosting

app/sprinkles/account/src/Database/Migrations/v400/CreateAdminUser.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public function seed()
6666
"email" => $email,
6767
"first_name" => $first_name,
6868
"last_name" => $last_name,
69-
"theme" => 'root',
7069
"password" => Password::hash($password)
7170
]);
7271

app/sprinkles/account/src/Database/Models/User.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class User extends Model
8181

8282
/**
8383
* Determine if the property for this object exists.
84+
*
8485
* We add relations here so that Twig will be able to find them.
8586
* See http://stackoverflow.com/questions/29514081/cannot-access-eloquent-attributes-on-twig/35908957#35908957
8687
* Every property in __get must also be implemented here for Twig to recognize it.
@@ -192,7 +193,7 @@ public static function exists($value, $identifier = 'user_name', $checkDeleted =
192193
/**
193194
* Return a cache instance specific to that user
194195
*
195-
* @return Illuminate\\Cache\\*Store
196+
* @return Illuminate\Contracts\Cache\Store
196197
*/
197198
public function getCache()
198199
{
@@ -263,6 +264,19 @@ public function group()
263264
return $this->belongsTo($classMapper->getClassMapping('group'), 'group_id');
264265
}
265266

267+
/**
268+
* Returns whether or not this user is the master user.
269+
*
270+
* @return bool
271+
*/
272+
public function isMaster()
273+
{
274+
$masterId = static::$ci->config['reserved_user_ids.master'];
275+
276+
// Need to use loose comparison for now, because some DBs return `id` as a string
277+
return ($this->id == $masterId);
278+
}
279+
266280
/**
267281
* Get the most recent activity for this user, based on the user's last_activity_id.
268282
*
@@ -317,7 +331,7 @@ public function lastActivityTime($type)
317331
* @param mixed[] $params Optional array of parameters used for this event handler.
318332
* @todo Transition to Laravel Event dispatcher to handle this
319333
*/
320-
public function onLogin($params = array())
334+
public function onLogin($params = [])
321335
{
322336
// Add a sign in activity (time is automatically set by database)
323337
static::$ci->userActivityLogger->info("User {$this->user_name} signed in.", [
@@ -329,15 +343,15 @@ public function onLogin($params = array())
329343

330344
if ($passwordType != "modern") {
331345
if (!isset($params['password'])) {
332-
error_log("Notice: Unhashed password must be supplied to update to modern password hashing.");
346+
Debug::debug("Notice: Unhashed password must be supplied to update to modern password hashing.");
333347
} else {
334348
// Hash the user's password and update
335349
$passwordHash = Password::hash($params['password']);
336350
if ($passwordHash === null) {
337-
error_log("Notice: outdated password hash could not be updated because the new hashing algorithm is not supported. Are you running PHP >= 5.3.7?");
351+
Debug::debug("Notice: outdated password hash could not be updated because the new hashing algorithm is not supported. Are you running PHP >= 5.3.7?");
338352
} else {
339353
$this->password = $passwordHash;
340-
error_log("Notice: outdated password hash has been automatically updated to modern hashing.");
354+
Debug::debug("Notice: outdated password hash has been automatically updated to modern hashing.");
341355
}
342356
}
343357
}
@@ -355,7 +369,7 @@ public function onLogin($params = array())
355369
* @param mixed[] $params Optional array of parameters used for this event handler.
356370
* @todo Transition to Laravel Event dispatcher to handle this
357371
*/
358-
public function onLogout($params = array())
372+
public function onLogout($params = [])
359373
{
360374
static::$ci->userActivityLogger->info("User {$this->user_name} signed out.", [
361375
'type' => 'sign_out'
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
{% block dashboard_navbar %}
22
<div class="navbar-custom-menu">
33
<ul class="nav navbar-nav">
4-
<!-- additional elements (e.g., menus, messages) before the user account drop down -->
5-
{% block dashboard_navbar_extra %} {% endblock %}
6-
<!-- User Account: style can be found in dropdown.less -->
7-
{% include "components/user-card.html.twig" %}
4+
{% if current_user.isMaster() %}
5+
<li class="hidden-xs hidden-sm"><a href="#">{{ translate("HEADER_MESSAGE_ROOT") | upper }}</a></li>
6+
{% endif %}
7+
8+
{# additional elements (e.g., menus, messages) before the user account drop down #}
9+
{% block dashboard_navbar_extra %} {% endblock %}
10+
11+
{# User Account: style can be found in dropdown.less #}
12+
{% include "components/user-card.html.twig" %}
813
</ul>
914
</div>
1015
{% endblock %}

app/sprinkles/admin/templates/layouts/dashboard.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
{% endblock %}
77

88
{% block body_attributes %}
9-
class="hold-transition skin-{{site.AdminLTE.skin}} sidebar-mini"
9+
{% if current_user.isMaster() %}
10+
class="hold-transition skin-red sidebar-mini"
11+
{% else %}
12+
class="hold-transition skin-{{site.AdminLTE.skin}} sidebar-mini"
13+
{% endif %}
1014
{% endblock %}
1115

1216
{% block content %}

app/sprinkles/root/templates/components/dashboard/navbar.html.twig

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/sprinkles/root/templates/layouts/dashboard.html.twig

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)