0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-02-12 12:09:14 +00:00
nextcloud_server/apps/encryption/lib/Users/Setup.php
Ferdinand Thiessen f3aa004b1c
refactor(encryption): Migrate away from Hooks to typed events
Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de>
Co-authored-by: Louis <louis@chmn.me>
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2024-10-15 18:33:06 +02:00

41 lines
926 B
PHP

<?php
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Encryption\Users;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
class Setup {
public function __construct(
private Crypt $crypt,
private KeyManager $keyManager,
) {
}
/**
* @param string $uid user id
* @param string $password user password
* @return bool
*/
public function setupUser($uid, $password) {
if (!$this->keyManager->userHasKeys($uid)) {
$keyPair = $this->crypt->createKeyPair();
return is_array($keyPair) ? $this->keyManager->storeKeyPair($uid, $password, $keyPair) : false;
}
return true;
}
/**
* make sure that all system keys exists
*/
public function setupSystem() {
$this->keyManager->validateShareKey();
$this->keyManager->validateMasterKey();
}
}