Skip to content

Commit

Permalink
adding daily schedule for syncing db and ldap
Browse files Browse the repository at this point in the history
minor code fixes
  • Loading branch information
lukas-staab committed Feb 24, 2024
1 parent 9485902 commit 27c1ea4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/Console/Commands/LegacyImport/ImportRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function handle()
if(!isset($realms[$role->realm_uid])){
$realms[$role->realm_uid] = Community::findByUid($role->realm_uid);
}
$this->comment('Importing Com ' . $role->name . ' to Realm ' . $role->realm_uid . ' ...');
$this->comment('Importing Com-Role ' . $role->name . ' to Realm ' . $role->realm_uid . ' ...');

$c = Committee::findByName($role->realm_uid, $role->gshort);
$r = $c?->roles()->where('cn', $role->rshort);
Expand Down Expand Up @@ -77,7 +77,6 @@ public function handle()
'from' => $assertion->from,
'until' => $assertion->until,
]);

}
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/Console/Commands/LegacyImport/ImportUserFromLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public function handle()
$ldapUser->setDn('uid=' . $user->username . ',ou=People,dc=open-administration,dc=de');
$ldapUser->save();
}
$realms[$user->realm_uid]->membersGroup()->members()->attach($ldapUser);
if(!$realms[$user->realm_uid]->membersGroup()->members()->exists($ldapUser)){
$realms[$user->realm_uid]->membersGroup()->members()->attach($ldapUser);
}
}
}
}
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('ldap:sync-roles')->dailyAt("00:01");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public function up(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
Schema::create('password_reset_tokens', static function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
Expand Down

0 comments on commit 27c1ea4

Please sign in to comment.