diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index c9bc2d5..6ad566f 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -92,6 +92,47 @@ public function destroyApp($id) return redirect()->route('admin.dashboard')->with('success', 'Service app deleted successfully.'); } + /** + * Update an app / service. + */ + public function updateApp(Request $request, $id) + { + $app = App::findOrFail($id); + + $request->validate([ + 'name' => 'required|string|max:255', + 'url' => 'required|url|max:255', + 'icon_svg' => 'nullable|string', + 'logo' => 'nullable|file|mimes:jpg,jpeg,png,webp,svg|max:2048', + 'color' => 'nullable|string|max:20', + 'desc' => 'nullable|string', + 'tag' => 'nullable|string|max:255', + ]); + + $logoPath = $app->logo; + if ($request->hasFile('logo')) { + if ($app->logo && file_exists(public_path($app->logo))) { + @unlink(public_path($app->logo)); + } + $file = $request->file('logo'); + $filename = time() . '_' . uniqid() . '.' . $file->getClientOriginalExtension(); + $file->move(public_path('uploads/logos'), $filename); + $logoPath = 'uploads/logos/' . $filename; + } + + $app->update([ + 'name' => $request->name, + 'url' => $request->url, + 'icon_svg' => $request->icon_svg, + 'logo' => $logoPath, + 'color' => $request->color ?? '#4f46e5', + 'desc' => $request->desc, + 'tag' => $request->tag ?? 'General', + ]); + + return redirect()->route('admin.dashboard')->with('success', 'Service app updated successfully.'); + } + /** * Store a new role. */ diff --git a/app/Models/User.php b/app/Models/User.php index 5dfd31f..b53d204 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -58,6 +58,24 @@ public function authorizedApps() ->pluck('app_id') ->toArray(); + // If no roles are assigned, user gets default access to Outlook email and Drive apps if registered + if (empty($roleIds)) { + $defaultAppIds = App::where(function ($query) { + $query->whereRaw('LOWER(name) LIKE ?', ['%outlook%']) + ->orWhereRaw('LOWER(name) LIKE ?', ['%mail%']) + ->orWhereRaw('LOWER(name) LIKE ?', ['%email%']) + ->orWhereRaw('LOWER(name) LIKE ?', ['%drive%']) + ->orWhereRaw('LOWER(name) LIKE ?', ['%onedrive%']) + ->orWhereRaw('LOWER(tag) LIKE ?', ['%outlook%']) + ->orWhereRaw('LOWER(tag) LIKE ?', ['%mail%']) + ->orWhereRaw('LOWER(tag) LIKE ?', ['%email%']) + ->orWhereRaw('LOWER(tag) LIKE ?', ['%drive%']) + ->orWhereRaw('LOWER(tag) LIKE ?', ['%onedrive%']); + })->pluck('id')->toArray(); + + $roleAppIds = array_unique(array_merge($roleAppIds, $defaultAppIds)); + } + // Get user overrides $overrides = $this->overrides()->get(); $allowedAppIds = $overrides->where('type', 'allow')->pluck('app_id')->toArray(); diff --git a/public/uploads/logos/1784030089_6a562389a4f9b.png b/public/uploads/logos/1784030089_6a562389a4f9b.png new file mode 100644 index 0000000..926a9bc Binary files /dev/null and b/public/uploads/logos/1784030089_6a562389a4f9b.png differ diff --git a/public/uploads/logos/1784015190_6a55e9565ba2d.jpg b/public/uploads/logos/1784030112_6a5623a07e3cf.jpg similarity index 100% rename from public/uploads/logos/1784015190_6a55e9565ba2d.jpg rename to public/uploads/logos/1784030112_6a5623a07e3cf.jpg diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 1744e1a..288aa2e 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -654,11 +654,22 @@