settings->mappedTemplate((array)$values); } /** Template for the login of an existing mailbox: its effective group template, else the mapped one */ public function templateFor(string $username, ?string $mapped): ?string { try { return $this->templates->templateForLogin($username, $mapped); } catch (Throwable $e) { error_log('mailcow: group template lookup failed for ' . $username . ': ' . $e->getMessage()); return $mapped; } } /** The IdP user may open the mailbox, an unlinked mailbox gets linked */ public function verifyLink(string $provider, string $username, string $externalId): bool { try { return $this->links->verify($provider, $username, $externalId); } catch (Throwable $e) { error_log('mailcow: IdP link check failed for ' . $username . ': ' . $e->getMessage()); return false; } } /** Before a mailbox is created on login: the IdP user must not own another mailbox */ public function mayCreate(string $provider, string $username, string $externalId): bool { try { return $this->links->mayCreate($provider, $username, $externalId); } catch (Throwable $e) { error_log('mailcow: IdP link check failed for ' . $username . ': ' . $e->getMessage()); return false; } } /** Links a mailbox created on login */ public function storeLink(string $provider, string $username, string $externalId): void { try { $this->links->link($provider, $username, $externalId); } catch (Throwable $e) { error_log('mailcow: IdP link could not be stored for ' . $username . ': ' . $e->getMessage()); } } }