diff --git a/app/Http/Controllers/Api/Web/ArtistsController.php b/app/Http/Controllers/Api/Web/ArtistsController.php index 1c069d2c..652ff0eb 100644 --- a/app/Http/Controllers/Api/Web/ArtistsController.php +++ b/app/Http/Controllers/Api/Web/ArtistsController.php @@ -20,6 +20,7 @@ namespace Poniverse\Ponyfm\Http\Controllers\Api\Web; +use Gate; use Poniverse\Ponyfm\Models\Album; use Poniverse\Ponyfm\Models\Comment; use Poniverse\Ponyfm\Models\Favourite; @@ -158,7 +159,7 @@ class ArtistsController extends ApiControllerBase return Response::json([ 'artist' => [ - 'id' => (int)$user->id, + 'id' => $user->id, 'name' => $user->display_name, 'slug' => $user->slug, 'is_archived' => (bool)$user->is_archived, @@ -174,7 +175,10 @@ class ArtistsController extends ApiControllerBase 'bio' => $user->bio, 'mlpforums_username' => $user->username, 'message_url' => $user->message_url, - 'user_data' => $userData + 'user_data' => $userData, + 'permissions' => [ + 'edit' => Gate::allows('edit', $user) + ] ] ], 200); } diff --git a/app/Models/User.php b/app/Models/User.php index 6513f059..89854764 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -241,7 +241,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon * @param string $roleName * @return bool */ - public function hasRole($roleName) + public function hasRole($roleName):bool { foreach ($this->roles as $role) { if ($role->name === $roleName) { diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index ac81c6d3..7fc5fd53 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -31,4 +31,8 @@ class UserPolicy public function getImages(User $userToAuthorize, User $user) { return $userToAuthorize->id === $user->id || $userToAuthorize->hasRole('admin'); } + + public function edit(User $userToAuthorize, User $user) { + return $userToAuthorize->id === $user->id; + } } diff --git a/public/templates/account/_layout.html b/public/templates/account/_layout.html index 60816d59..0504e5c4 100644 --- a/public/templates/account/_layout.html +++ b/public/templates/account/_layout.html @@ -1,8 +1,16 @@ diff --git a/public/templates/account/tracks.html b/public/templates/account/tracks.html index 0d06e0e7..28cbd00d 100644 --- a/public/templates/account/tracks.html +++ b/public/templates/account/tracks.html @@ -2,7 +2,7 @@
diff --git a/public/templates/uploader/index.html b/public/templates/uploader/index.html index 21178622..bde8baee 100644 --- a/public/templates/uploader/index.html +++ b/public/templates/uploader/index.html @@ -24,7 +24,7 @@ - + Publish {{upload.name}} diff --git a/resources/assets/scripts/app/app.coffee b/resources/assets/scripts/app/app.coffee index 561ce43d..4da6bcec 100644 --- a/resources/assets/scripts/app/app.coffee +++ b/resources/assets/scripts/app/app.coffee @@ -148,48 +148,6 @@ ponyfm.config [ templateUrl: '/templates/uploader/index.html' controller: 'uploader' - # Account - - state.state 'account', - url: '/account' - abstract: true - templateUrl: '/templates/account/_layout.html' - - state.state 'account.settings', - url: '' - templateUrl: '/templates/account/settings.html' - controller: 'account-settings' - - state.state 'account.tracks', - url: '/tracks' - templateUrl: '/templates/account/tracks.html' - controller: 'account-tracks' - - state.state 'account.tracks.edit', - url: '/edit/:track_id' - templateUrl: '/templates/account/track.html' - controller: 'account-track' - - state.state 'account.albums', - url: '/albums' - templateUrl: '/templates/account/albums.html' - controller: 'account-albums' - - state.state 'account.albums.create', - url: '/create' - templateUrl: '/templates/account/album.html' - controller: 'account-albums-edit' - - state.state 'account.albums.edit', - url: '/edit/:album_id' - templateUrl: '/templates/account/album.html' - controller: 'account-albums-edit' - - state.state 'account.playlists', - url: '/playlists' - templateUrl: '/templates/account/playlists.html' - controller: 'account-playlists' - state.state 'favourites', url: '/account/favourites' abstract: true @@ -368,6 +326,50 @@ ponyfm.config [ templateUrl: '/templates/artists/favourites.html' controller: 'artist-favourites' + + # Account + + state.state 'content.artist.account', + url: '/account' + abstract: true + templateUrl: '/templates/account/_layout.html' + + state.state 'content.artist.account.settings', + url: '' + templateUrl: '/templates/account/settings.html' + controller: 'account-settings' + + state.state 'content.artist.account.tracks', + url: '/tracks' + templateUrl: '/templates/account/tracks.html' + controller: 'account-tracks' + + state.state 'content.artist.account.tracks.edit', + url: '/edit/:track_id' + templateUrl: '/templates/account/track.html' + controller: 'account-track' + + state.state 'content.artist.account.albums', + url: '/albums' + templateUrl: '/templates/account/albums.html' + controller: 'account-albums' + + state.state 'content.artist.account.albums.create', + url: '/create' + templateUrl: '/templates/account/album.html' + controller: 'account-albums-edit' + + state.state 'content.artist.account.albums.edit', + url: '/edit/:album_id' + templateUrl: '/templates/account/album.html' + controller: 'account-albums-edit' + + state.state 'content.artist.account.playlists', + url: '/playlists' + templateUrl: '/templates/account/playlists.html' + controller: 'account-playlists' + + location.html5Mode(true); $dialogProvider.options dialogFade: true diff --git a/resources/views/shared/_app_layout.blade.php b/resources/views/shared/_app_layout.blade.php index 06ed3127..2902efec 100644 --- a/resources/views/shared/_app_layout.blade.php +++ b/resources/views/shared/_app_layout.blade.php @@ -54,8 +54,8 @@