Skip to content

Commit

Permalink
add nextcloud info to idp (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiritin authored May 26, 2024
2 parents b6184f4 + 660d025 commit cc4c2a2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/Filament/Resources/GroupResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ public static function form(Form $form): Form
->label('Public ID')
->content(fn(?Group $record): string => $record?->hashid() ?? '-'),
]),
TextInput::make('system_name')
->label('System Name')
->hint('Unique system name, should be left empty in most cases.')
->unique('groups', 'system_name', ignoreRecord: true)
->disabled(fn(?Group $record) => $record?->exists),
TextInput::make('name')
->hint('Translatable')
->hintIcon('heroicon-m-language')
->required(),
TextInput::make('nextcloud_folder_name')
->label('Nextcloud Folder Name')
->hint('Leave empty if the group should not be allowed to access Nextcloud.')
->unique('groups', 'nextcloud_folder_name', ignoreRecord: true),
Textarea::make('description')->rows(5),
]),
]),
Expand Down
11 changes: 11 additions & 0 deletions app/Http/Resources/V1/UserinfoResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,28 @@ public function toArray($request)
$data = [];

$data['sub'] = $this->hashid;
$this->loadMissing('groups');

if ($this->scopeCheck('email')) {
$data['email'] = $this->email;
$data['email_verified'] = !is_null($this->email_verified_at);
}

if ($this->scopeCheck('profile')) {
$data['name'] = $this->name;

$data['avatar'] = ($request->user()->profile_photo_path) ? Storage::disk('s3-avatars')->url($request->user()->profile_photo_path) : null;
}
if ($this->whenLoaded('groups') && $this->scopeCheck('groups')) {
$data['groups'] = $this->groups->pluck('hashid');
}
/**
* APP Specific: NEXTCLOUD
*/
if ($this->scopeCheck('nextcloud')) {
$data['nextcloud_groups'] = $this->groups->whereNotNull('nextcloud_folder_name')->pluck('nextcloud_folder_name');
$data['nextcloud_admin'] = $this->groups->contains('system_name', 'nextcloud_admins');
}

return $data;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
public function up(): void
{
Schema::table('groups', function (Blueprint $table) {
$table->string('nextcloud_folder_name')->nullable()->after('logo');
});
}

public function down(): void
{
Schema::table('groups', function (Blueprint $table) {
$table->dropColumn('nextcloud_folder_name');
});
}
};

0 comments on commit cc4c2a2

Please sign in to comment.