Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nextcloud info to idp #89

Merged
merged 1 commit into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -30,18 +30,29 @@ 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->filter(fn(Group $group
) => $group->pivot->level !== GroupUserLevel::Invited)->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');
});
}
};
Loading