From c106a9d293473233bd2e0dcd5a8e7789a98d8ab6 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
Date: Tue, 3 Dec 2019 19:31:31 +0100
Subject: [PATCH] Set last-password-confirmation for setup

Else you have to enter your password directly after setup if you do
anything admin worthy.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
---
 lib/private/Setup.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 266c70846c6..4ebd5618189 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -49,6 +49,7 @@ use OC\Authentication\Token\DefaultTokenCleanupJob;
 use OC\Authentication\Token\DefaultTokenProvider;
 use OC\Log\Rotate;
 use OC\Preview\BackgroundCleanupJob;
+use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\Defaults;
 use OCP\IGroup;
 use OCP\IL10N;
@@ -421,6 +422,9 @@ class Setup {
 			$userSession->login($username, $password);
 			$userSession->createSessionToken($request, $userSession->getUser()->getUID(), $username, $password);
 
+			$session = $userSession->getSession();
+			$session->set('last-password-confirm', \OC::$server->query(ITimeFactory::class)->getTime());
+
 			// Set email for admin
 			if (!empty($options['adminemail'])) {
 				$config->setUserValue($user->getUID(), 'settings', 'email', $options['adminemail']);
-- 
GitLab