aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/lib/Service/OwnershipTransferService.php27
-rw-r--r--apps/files_sharing/l10n/fr.js16
-rw-r--r--apps/files_sharing/l10n/fr.json16
-rw-r--r--apps/provisioning_api/l10n/hu.js11
-rw-r--r--apps/provisioning_api/l10n/hu.json11
-rw-r--r--apps/user_status/l10n/fr.js3
-rw-r--r--apps/user_status/l10n/fr.json3
-rw-r--r--build/psalm-baseline-ocp.xml5
-rw-r--r--core/Controller/LoginController.php5
-rw-r--r--core/Controller/RecommendedAppsController.php8
-rw-r--r--core/Controller/SetupController.php8
-rw-r--r--core/Controller/TwoFactorChallengeController.php5
-rw-r--r--core/Middleware/TwoFactorMiddleware.php6
-rw-r--r--lib/base.php6
-rw-r--r--lib/private/URLGenerator.php49
-rw-r--r--lib/private/legacy/OC_Util.php45
-rw-r--r--lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php12
-rw-r--r--lib/public/IURLGenerator.php8
-rw-r--r--psalm.xml1
-rw-r--r--tests/Core/Command/Apps/AppsDisableTest.php18
-rw-r--r--tests/Core/Command/Apps/AppsEnableTest.php26
-rw-r--r--tests/Core/Controller/LoginControllerTest.php32
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php7
-rw-r--r--tests/lib/UrlGeneratorTest.php111
-rw-r--r--tests/lib/UtilTest.php105
25 files changed, 333 insertions, 211 deletions
diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php
index ecb2365ef1b..93a3a188399 100644
--- a/apps/files/lib/Service/OwnershipTransferService.php
+++ b/apps/files/lib/Service/OwnershipTransferService.php
@@ -43,6 +43,7 @@ use OCP\Files\IHomeStorage;
use OCP\Files\InvalidPathException;
use OCP\Files\Mount\IMountManager;
use OCP\IUser;
+use OCP\IUserManager;
use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use Symfony\Component\Console\Helper\ProgressBar;
@@ -69,14 +70,19 @@ class OwnershipTransferService {
/** @var IUserMountCache */
private $userMountCache;
+ /** @var IUserManager */
+ private $userManager;
+
public function __construct(IEncryptionManager $manager,
IShareManager $shareManager,
IMountManager $mountManager,
- IUserMountCache $userMountCache) {
+ IUserMountCache $userMountCache,
+ IUserManager $userManager) {
$this->encryptionManager = $manager;
$this->shareManager = $shareManager;
$this->mountManager = $mountManager;
$this->userMountCache = $userMountCache;
+ $this->userManager = $userManager;
}
/**
@@ -401,13 +407,20 @@ class OwnershipTransferService {
$share->setSharedBy($destinationUid);
}
+ if ($share->getShareType() === IShare::TYPE_USER &&
+ !$this->userManager->userExists($share->getSharedWith())) {
+ // stray share with deleted user
+ $output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted user "' . $share->getSharedWith() . '", deleting</error>');
+ $this->shareManager->deleteShare($share);
+ continue;
+ } else {
+ // trigger refetching of the node so that the new owner and mountpoint are taken into account
+ // otherwise the checks on the share update will fail due to the original node not being available in the new user scope
+ $this->userMountCache->clear();
+ $share->setNodeId($share->getNode()->getId());
- // trigger refetching of the node so that the new owner and mountpoint are taken into account
- // otherwise the checks on the share update will fail due to the original node not being available in the new user scope
- $this->userMountCache->clear();
- $share->setNodeId($share->getNode()->getId());
-
- $this->shareManager->updateShare($share);
+ $this->shareManager->updateShare($share);
+ }
}
} catch (\OCP\Files\NotFoundException $e) {
$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>');
diff --git a/apps/files_sharing/l10n/fr.js b/apps/files_sharing/l10n/fr.js
index c21620edfce..d0a4a320930 100644
--- a/apps/files_sharing/l10n/fr.js
+++ b/apps/files_sharing/l10n/fr.js
@@ -103,6 +103,7 @@ OC.L10N.register(
"Please specify a file or folder path" : "Veuillez indiquer un fichier ou un chemin",
"Wrong path, file/folder doesn't exist" : "Mauvais chemin, Le fichier/dossier n'existe pas",
"Could not create share" : "Impossible de créer le partage",
+ "Invalid permissions" : "Autorisations non valides",
"Please specify a valid user" : "Veuillez entrer un utilisateur valide",
"Group sharing is disabled by the administrator" : "Le partage de groupe a été désactivé par l'administrateur",
"Please specify a valid group" : "Veuillez entrer un groupe valide",
@@ -112,6 +113,8 @@ OC.L10N.register(
"Sharing %s sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled" : "Partager %s en envoyant le mot de passe par Nextcloud Talk a échoué car Nextcloud Talk n'est pas activé.",
"Invalid date, date format must be YYYY-MM-DD" : "Date non valide, le format doit être DD/MM/YYYY",
"Sharing %1$s failed because the back end does not allow shares from type %2$s" : "Le partage %1$s a échoué parce que l'infrastructure n'autorise pas les partages du type %2$s",
+ "Please specify a valid federated user ID" : "Merci de spécifier un utilisateur fédéré valide",
+ "Please specify a valid federated group ID" : "Merci de spécifier un groupe fédéré valide",
"You cannot share to a Circle if the app is not enabled" : "Vous ne pouvez pas partager au Cercle si l'application n'est pas activée",
"Please specify a valid circle" : "Veuillez entrer un cercle valide",
"Sharing %s failed because the back end does not support room shares" : "Le partage %s a échoué parce que l'arrière-plan ne prend pas en charge les partages.",
@@ -120,9 +123,12 @@ OC.L10N.register(
"Could not lock node" : "Impossible de verrouiller le nœud",
"Could not lock path" : "Impossible de verrouiller le chemin",
"Wrong or no update parameter given" : "Mauvais ou aucun paramètre donné ",
+ "Cannot change permissions for public share links" : "Impossible de changer les autorisations pour les liens publics partagés",
+ "\"Sending the password by Nextcloud Talk\" for sharing a file or folder failed because Nextcloud Talk is not enabled." : "\"L'envoi du mot de passe par Nextcloud Talk\" pour partager un fichier a échoué car Nextcloud Talk n'est pas activé",
"shared by %s" : "partagé par %s",
"Download all files" : "Télécharger tous les fichiers",
"Direct link" : "Lien direct",
+ "Add to your %s" : "Ajouter à votre %s ",
"Share API is disabled" : "l'API de partage est désactivée",
"File sharing" : "Partage de fichier",
"Share will expire tomorrow" : "Le partage expirera demain",
@@ -135,6 +141,13 @@ OC.L10N.register(
"This application enables users to share files within Nextcloud. If enabled, the admin can choose which groups can share files. The applicable users can then share files and folders with other users and groups within Nextcloud. In addition, if the admin enables the share link feature, an external link can be used to share files with other users outside of Nextcloud. Admins can also enforce passwords, expirations dates, and enable server to server sharing via share links, as well as sharing from mobile devices.\nTurning the feature off removes shared files and folders on the server for all share recipients, and also on the sync clients and mobile apps. More information is available in the Nextcloud Documentation." : "Cette application permet aux utilisateurs de partager des fichiers dans Nextcloud. Si cette option est activée, l'administrateur peut choisir quels groupes peuvent partager des fichiers. Les utilisateurs concernés peuvent ensuite partager des fichiers et des dossiers avec d'autres utilisateurs et groupes au sein de Nextcloud. De plus, si l'administrateur active la fonction de lien de partage, un lien externe peut être utilisé pour partager des fichiers avec d'autres utilisateurs en dehors de Nextcloud. Les administrateurs peuvent également faire respecter les mots de passe, les dates d'expiration et permettre le partage de serveur à serveur via des liens de partage, aussi bien que le partage à partir d'appareils mobiles.\nDésactiver cette fonction supprime les fichiers et dossiers partagés sur le serveur pour tous les destinataires de partage, ainsi que sur les clients de synchronisation et les applications mobiles. Plus d'informations sont disponibles dans la documentation Nextcloud.",
"Sharing" : "Partage",
"Accept user and group shares by default" : "Par défaut accepter les partages utilisateur et groupe",
+ "Error while toggling options" : "Erreur pendant le choix des options",
+ "Set default folder for accepted shares" : "Définir le répertoire par défaut pour les partages acceptés",
+ "Reset" : "Réinitialiser",
+ "Reset folder to system default" : "Réinitialiser le répertoire par défaut du système",
+ "Choose a default folder for accepted shares" : "Choisir un répertoire par défaut pour les partagés acceptés",
+ "Invalid path selected" : "Chemin non valide sélectionné",
+ "Unknown error" : "Erreur inconnue",
"Allow editing" : "Autoriser la modification",
"Allow creating" : "Autoriser la création",
"Allow deleting" : "Autoriser la suppression",
@@ -179,6 +192,7 @@ OC.L10N.register(
"Create a new share link" : "Créer un nouveau lien de partage",
"{shareWith} by {initiator}" : "{shareWith} par {initiator}",
"Shared via link by {initiator}" : "Partagé par lien par {initiator}",
+ "Mail share ({label})" : "Partage par courriel ({label}) ",
"Share link ({label})" : "Partager le lien ({label})",
"Share link" : "Lien de partage",
"Error, please enter proper password and/or expiration date" : "Erreur. Merci d'entrer un mot de passe valide et/ou une date d'expiration",
@@ -199,7 +213,9 @@ OC.L10N.register(
"Expires {relativetime}" : "Expire {relativetime}",
"this share just expired." : "ce partage vient d'expirer",
"Link to a file" : "Lier à un fichier",
+ "Error creating the share: {errorMessage}" : "Erreur à la création du partage : {errorMessage} ",
"Error creating the share" : "Erreur lors de la création du partage",
+ "Error updating the share: {errorMessage}" : "Erreur à la mise à jour du partage\\: {errorMessage} ",
"Error updating the share" : "Erreur lors de la mise à jour du partage",
"Shared" : "Partagé",
"Share" : "Partager",
diff --git a/apps/files_sharing/l10n/fr.json b/apps/files_sharing/l10n/fr.json
index c148923adef..1a3c29c88da 100644
--- a/apps/files_sharing/l10n/fr.json
+++ b/apps/files_sharing/l10n/fr.json
@@ -101,6 +101,7 @@
"Please specify a file or folder path" : "Veuillez indiquer un fichier ou un chemin",
"Wrong path, file/folder doesn't exist" : "Mauvais chemin, Le fichier/dossier n'existe pas",
"Could not create share" : "Impossible de créer le partage",
+ "Invalid permissions" : "Autorisations non valides",
"Please specify a valid user" : "Veuillez entrer un utilisateur valide",
"Group sharing is disabled by the administrator" : "Le partage de groupe a été désactivé par l'administrateur",
"Please specify a valid group" : "Veuillez entrer un groupe valide",
@@ -110,6 +111,8 @@
"Sharing %s sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled" : "Partager %s en envoyant le mot de passe par Nextcloud Talk a échoué car Nextcloud Talk n'est pas activé.",
"Invalid date, date format must be YYYY-MM-DD" : "Date non valide, le format doit être DD/MM/YYYY",
"Sharing %1$s failed because the back end does not allow shares from type %2$s" : "Le partage %1$s a échoué parce que l'infrastructure n'autorise pas les partages du type %2$s",
+ "Please specify a valid federated user ID" : "Merci de spécifier un utilisateur fédéré valide",
+ "Please specify a valid federated group ID" : "Merci de spécifier un groupe fédéré valide",
"You cannot share to a Circle if the app is not enabled" : "Vous ne pouvez pas partager au Cercle si l'application n'est pas activée",
"Please specify a valid circle" : "Veuillez entrer un cercle valide",
"Sharing %s failed because the back end does not support room shares" : "Le partage %s a échoué parce que l'arrière-plan ne prend pas en charge les partages.",
@@ -118,9 +121,12 @@
"Could not lock node" : "Impossible de verrouiller le nœud",
"Could not lock path" : "Impossible de verrouiller le chemin",
"Wrong or no update parameter given" : "Mauvais ou aucun paramètre donné ",
+ "Cannot change permissions for public share links" : "Impossible de changer les autorisations pour les liens publics partagés",
+ "\"Sending the password by Nextcloud Talk\" for sharing a file or folder failed because Nextcloud Talk is not enabled." : "\"L'envoi du mot de passe par Nextcloud Talk\" pour partager un fichier a échoué car Nextcloud Talk n'est pas activé",
"shared by %s" : "partagé par %s",
"Download all files" : "Télécharger tous les fichiers",
"Direct link" : "Lien direct",
+ "Add to your %s" : "Ajouter à votre %s ",
"Share API is disabled" : "l'API de partage est désactivée",
"File sharing" : "Partage de fichier",
"Share will expire tomorrow" : "Le partage expirera demain",
@@ -133,6 +139,13 @@
"This application enables users to share files within Nextcloud. If enabled, the admin can choose which groups can share files. The applicable users can then share files and folders with other users and groups within Nextcloud. In addition, if the admin enables the share link feature, an external link can be used to share files with other users outside of Nextcloud. Admins can also enforce passwords, expirations dates, and enable server to server sharing via share links, as well as sharing from mobile devices.\nTurning the feature off removes shared files and folders on the server for all share recipients, and also on the sync clients and mobile apps. More information is available in the Nextcloud Documentation." : "Cette application permet aux utilisateurs de partager des fichiers dans Nextcloud. Si cette option est activée, l'administrateur peut choisir quels groupes peuvent partager des fichiers. Les utilisateurs concernés peuvent ensuite partager des fichiers et des dossiers avec d'autres utilisateurs et groupes au sein de Nextcloud. De plus, si l'administrateur active la fonction de lien de partage, un lien externe peut être utilisé pour partager des fichiers avec d'autres utilisateurs en dehors de Nextcloud. Les administrateurs peuvent également faire respecter les mots de passe, les dates d'expiration et permettre le partage de serveur à serveur via des liens de partage, aussi bien que le partage à partir d'appareils mobiles.\nDésactiver cette fonction supprime les fichiers et dossiers partagés sur le serveur pour tous les destinataires de partage, ainsi que sur les clients de synchronisation et les applications mobiles. Plus d'informations sont disponibles dans la documentation Nextcloud.",
"Sharing" : "Partage",
"Accept user and group shares by default" : "Par défaut accepter les partages utilisateur et groupe",
+ "Error while toggling options" : "Erreur pendant le choix des options",
+ "Set default folder for accepted shares" : "Définir le répertoire par défaut pour les partages acceptés",
+ "Reset" : "Réinitialiser",
+ "Reset folder to system default" : "Réinitialiser le répertoire par défaut du système",
+ "Choose a default folder for accepted shares" : "Choisir un répertoire par défaut pour les partagés acceptés",
+ "Invalid path selected" : "Chemin non valide sélectionné",
+ "Unknown error" : "Erreur inconnue",
"Allow editing" : "Autoriser la modification",
"Allow creating" : "Autoriser la création",
"Allow deleting" : "Autoriser la suppression",
@@ -177,6 +190,7 @@
"Create a new share link" : "Créer un nouveau lien de partage",
"{shareWith} by {initiator}" : "{shareWith} par {initiator}",
"Shared via link by {initiator}" : "Partagé par lien par {initiator}",
+ "Mail share ({label})" : "Partage par courriel ({label}) ",
"Share link ({label})" : "Partager le lien ({label})",
"Share link" : "Lien de partage",
"Error, please enter proper password and/or expiration date" : "Erreur. Merci d'entrer un mot de passe valide et/ou une date d'expiration",
@@ -197,7 +211,9 @@
"Expires {relativetime}" : "Expire {relativetime}",
"this share just expired." : "ce partage vient d'expirer",
"Link to a file" : "Lier à un fichier",
+ "Error creating the share: {errorMessage}" : "Erreur à la création du partage : {errorMessage} ",
"Error creating the share" : "Erreur lors de la création du partage",
+ "Error updating the share: {errorMessage}" : "Erreur à la mise à jour du partage\\: {errorMessage} ",
"Error updating the share" : "Erreur lors de la mise à jour du partage",
"Shared" : "Partagé",
"Share" : "Partager",
diff --git a/apps/provisioning_api/l10n/hu.js b/apps/provisioning_api/l10n/hu.js
index 0da670b6fcd..8b782dbaaf0 100644
--- a/apps/provisioning_api/l10n/hu.js
+++ b/apps/provisioning_api/l10n/hu.js
@@ -1,8 +1,17 @@
OC.L10N.register(
"provisioning_api",
{
+ "Email confirmation" : "E-mail-cím megerősítése",
+ "To enable the email address %s please click the button below." : "A(z) %s e-mail-cím engedélyezéséhez kattintson a lenti gombra.",
+ "Confirm" : "Megerősítés",
+ "Email was already removed from account and cannot be confirmed anymore." : "Az e-mail már el lett távolítva a fiókból, és már nem erősíthető meg.",
+ "Could not verify mail because the token is expired." : "Az e-mail-címet nem lehet megerősíteni, mert a token lejárt.",
+ "Could not verify mail because the token is invalid." : "Az e-mail-címet nem lehet megerősíteni, mert a token érvénytelen.",
+ "An unexpected error occurred. Please contact your admin." : "Váratlan hiba történt. Lépjen kapcsolatba a rendszergazdával.",
+ "Email confirmation successful" : "Az e-mail-cím megerősítése sikeres",
"Provisioning API" : "Provisioning API",
"This application enables a set of APIs that external systems can use to manage users, groups and apps." : "Ez az alkalmazás bekapcsol egy API készletet, melyeket külső rendszerek arra használhatnak, hogy a felhasználókat, csoportokat és alkalmazásokat kezeljenek.",
- "This application enables a set of APIs that external systems can use to create, edit, delete and query user\n\t\tattributes, query, set and remove groups, set quota and query total storage used in Nextcloud. Group admin users\n\t\tcan also query Nextcloud and perform the same functions as an admin for groups they manage. The API also enables\n\t\tan admin to query for active Nextcloud applications, application info, and to enable or disable an app remotely.\n\t\tOnce the app is enabled, HTTP requests can be used via a Basic Auth header to perform any of the functions\n\t\tlisted above. More information is available in the Provisioning API documentation, including example calls\n\t\tand server responses." : "Ez az alkalmazás bekapcsol egy API készletet, melyeket külső rendszerek használhatnak a felhasználók létrehozására,\n\t\tszerkesztésére, törlésére és attribútumok lekérdezésére, csoportok beállítására, eltávolítására és\n\t\tlekérdezésére, kvóta beállítására és a teljes tárhely lekérdezésére a Nextcloudban. A csoport admin felhasználók\n\t\tlekérdezhetik a Nextcloudot, és ugyanazokat a funkciókat hajthatják végre, mint az adminisztrátor az általuk\n\t\tkezelt csoportoknál. Az API szintén megengedi a rendszergazdának az aktív nextcloudos alkalmazások,\n\t\talkalmazásinformációk lekérdezését, valamint az alkalmazások távoli engedélyezését vagy letiltását. Miután\n\t\tengedélyezte az alkalmazást, a HTTP-kéréseket a Basic hitelesítési fejlécen keresztül fel lehet használni\n\t\tbármely, a feljebb felsorolt funkció végrehajtására. További információ a Provisioning API dokumentációjában\n\t\ttalálható, beleértve a példahívásokat és a kiszolgáló válaszait is."
+ "This application enables a set of APIs that external systems can use to create, edit, delete and query user\n\t\tattributes, query, set and remove groups, set quota and query total storage used in Nextcloud. Group admin users\n\t\tcan also query Nextcloud and perform the same functions as an admin for groups they manage. The API also enables\n\t\tan admin to query for active Nextcloud applications, application info, and to enable or disable an app remotely.\n\t\tOnce the app is enabled, HTTP requests can be used via a Basic Auth header to perform any of the functions\n\t\tlisted above. More information is available in the Provisioning API documentation, including example calls\n\t\tand server responses." : "Ez az alkalmazás bekapcsol egy API készletet, melyeket külső rendszerek használhatnak a felhasználók létrehozására,\n\t\tszerkesztésére, törlésére és attribútumok lekérdezésére, csoportok beállítására, eltávolítására és\n\t\tlekérdezésére, kvóta beállítására és a teljes tárhely lekérdezésére a Nextcloudban. A csoport admin felhasználók\n\t\tlekérdezhetik a Nextcloudot, és ugyanazokat a funkciókat hajthatják végre, mint az adminisztrátor az általuk\n\t\tkezelt csoportoknál. Az API szintén megengedi a rendszergazdának az aktív nextcloudos alkalmazások,\n\t\talkalmazásinformációk lekérdezését, valamint az alkalmazások távoli engedélyezését vagy letiltását. Miután\n\t\tengedélyezte az alkalmazást, a HTTP-kéréseket a Basic hitelesítési fejlécen keresztül fel lehet használni\n\t\tbármely, a feljebb felsorolt funkció végrehajtására. További információ a Provisioning API dokumentációjában\n\t\ttalálható, beleértve a példahívásokat és a kiszolgáló válaszait is.",
+ "An unexpected error occurred. Please consult your sysadmin." : "Váratlan hiba történt. Konzultáljon a rendszergazdával."
},
"nplurals=2; plural=(n != 1);");
diff --git a/apps/provisioning_api/l10n/hu.json b/apps/provisioning_api/l10n/hu.json
index 51647fc6e65..555ba19f353 100644
--- a/apps/provisioning_api/l10n/hu.json
+++ b/apps/provisioning_api/l10n/hu.json
@@ -1,6 +1,15 @@
{ "translations": {
+ "Email confirmation" : "E-mail-cím megerősítése",
+ "To enable the email address %s please click the button below." : "A(z) %s e-mail-cím engedélyezéséhez kattintson a lenti gombra.",
+ "Confirm" : "Megerősítés",
+ "Email was already removed from account and cannot be confirmed anymore." : "Az e-mail már el lett távolítva a fiókból, és már nem erősíthető meg.",
+ "Could not verify mail because the token is expired." : "Az e-mail-címet nem lehet megerősíteni, mert a token lejárt.",
+ "Could not verify mail because the token is invalid." : "Az e-mail-címet nem lehet megerősíteni, mert a token érvénytelen.",
+ "An unexpected error occurred. Please contact your admin." : "Váratlan hiba történt. Lépjen kapcsolatba a rendszergazdával.",
+ "Email confirmation successful" : "Az e-mail-cím megerősítése sikeres",
"Provisioning API" : "Provisioning API",
"This application enables a set of APIs that external systems can use to manage users, groups and apps." : "Ez az alkalmazás bekapcsol egy API készletet, melyeket külső rendszerek arra használhatnak, hogy a felhasználókat, csoportokat és alkalmazásokat kezeljenek.",
- "This application enables a set of APIs that external systems can use to create, edit, delete and query user\n\t\tattributes, query, set and remove groups, set quota and query total storage used in Nextcloud. Group admin users\n\t\tcan also query Nextcloud and perform the same functions as an admin for groups they manage. The API also enables\n\t\tan admin to query for active Nextcloud applications, application info, and to enable or disable an app remotely.\n\t\tOnce the app is enabled, HTTP requests can be used via a Basic Auth header to perform any of the functions\n\t\tlisted above. More information is available in the Provisioning API documentation, including example calls\n\t\tand server responses." : "Ez az alkalmazás bekapcsol egy API készletet, melyeket külső rendszerek használhatnak a felhasználók létrehozására,\n\t\tszerkesztésére, törlésére és attribútumok lekérdezésére, csoportok beállítására, eltávolítására és\n\t\tlekérdezésére, kvóta beállítására és a teljes tárhely lekérdezésére a Nextcloudban. A csoport admin felhasználók\n\t\tlekérdezhetik a Nextcloudot, és ugyanazokat a funkciókat hajthatják végre, mint az adminisztrátor az általuk\n\t\tkezelt csoportoknál. Az API szintén megengedi a rendszergazdának az aktív nextcloudos alkalmazások,\n\t\talkalmazásinformációk lekérdezését, valamint az alkalmazások távoli engedélyezését vagy letiltását. Miután\n\t\tengedélyezte az alkalmazást, a HTTP-kéréseket a Basic hitelesítési fejlécen keresztül fel lehet használni\n\t\tbármely, a feljebb felsorolt funkció végrehajtására. További információ a Provisioning API dokumentációjában\n\t\ttalálható, beleértve a példahívásokat és a kiszolgáló válaszait is."
+ "This application enables a set of APIs that external systems can use to create, edit, delete and query user\n\t\tattributes, query, set and remove groups, set quota and query total storage used in Nextcloud. Group admin users\n\t\tcan also query Nextcloud and perform the same functions as an admin for groups they manage. The API also enables\n\t\tan admin to query for active Nextcloud applications, application info, and to enable or disable an app remotely.\n\t\tOnce the app is enabled, HTTP requests can be used via a Basic Auth header to perform any of the functions\n\t\tlisted above. More information is available in the Provisioning API documentation, including example calls\n\t\tand server responses." : "Ez az alkalmazás bekapcsol egy API készletet, melyeket külső rendszerek használhatnak a felhasználók létrehozására,\n\t\tszerkesztésére, törlésére és attribútumok lekérdezésére, csoportok beállítására, eltávolítására és\n\t\tlekérdezésére, kvóta beállítására és a teljes tárhely lekérdezésére a Nextcloudban. A csoport admin felhasználók\n\t\tlekérdezhetik a Nextcloudot, és ugyanazokat a funkciókat hajthatják végre, mint az adminisztrátor az általuk\n\t\tkezelt csoportoknál. Az API szintén megengedi a rendszergazdának az aktív nextcloudos alkalmazások,\n\t\talkalmazásinformációk lekérdezését, valamint az alkalmazások távoli engedélyezését vagy letiltását. Miután\n\t\tengedélyezte az alkalmazást, a HTTP-kéréseket a Basic hitelesítési fejlécen keresztül fel lehet használni\n\t\tbármely, a feljebb felsorolt funkció végrehajtására. További információ a Provisioning API dokumentációjában\n\t\ttalálható, beleértve a példahívásokat és a kiszolgáló válaszait is.",
+ "An unexpected error occurred. Please consult your sysadmin." : "Váratlan hiba történt. Konzultáljon a rendszergazdával."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
} \ No newline at end of file
diff --git a/apps/user_status/l10n/fr.js b/apps/user_status/l10n/fr.js
index f42a9a2749c..083bb6cc3c5 100644
--- a/apps/user_status/l10n/fr.js
+++ b/apps/user_status/l10n/fr.js
@@ -3,12 +3,13 @@ OC.L10N.register(
{
"Recent statuses" : "Statuts récents",
"In a meeting" : "En réunion",
- "Commuting" : "Navetter",
+ "Commuting" : "En transit",
"Out sick" : "En congé de maladie",
"Vacationing" : "En vacances",
"Working remotely" : "Travail à distance",
"User status" : "Statut utilisateur",
"Clear status message after" : "Effacer le message d'état après",
+ "What is your status?" : "Quel est votre statut ?",
"Set status" : "Définir le statut",
"Online status" : "Statut en ligne",
"Status message" : "Message d'état",
diff --git a/apps/user_status/l10n/fr.json b/apps/user_status/l10n/fr.json
index 6d84db21eb1..cfcd68dfa67 100644
--- a/apps/user_status/l10n/fr.json
+++ b/apps/user_status/l10n/fr.json
@@ -1,12 +1,13 @@
{ "translations": {
"Recent statuses" : "Statuts récents",
"In a meeting" : "En réunion",
- "Commuting" : "Navetter",
+ "Commuting" : "En transit",
"Out sick" : "En congé de maladie",
"Vacationing" : "En vacances",
"Working remotely" : "Travail à distance",
"User status" : "Statut utilisateur",
"Clear status message after" : "Effacer le message d'état après",
+ "What is your status?" : "Quel est votre statut ?",
"Set status" : "Définir le statut",
"Online status" : "Statut en ligne",
"Status message" : "Message d'état",
diff --git a/build/psalm-baseline-ocp.xml b/build/psalm-baseline-ocp.xml
index 3306f76e2ce..6f6aa5b85e3 100644
--- a/build/psalm-baseline-ocp.xml
+++ b/build/psalm-baseline-ocp.xml
@@ -50,6 +50,11 @@
<code>array</code>
</InvalidReturnType>
</file>
+ <file src="lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php">
+ <UndefinedClass occurrences="1">
+ <code>\OC</code>
+ </UndefinedClass>
+ </file>
<file src="lib/public/AppFramework/Http/Response.php">
<UndefinedClass occurrences="2">
<code>\OC</code>
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index 8a96db97c9e..15ec8365c19 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -38,7 +38,6 @@ use OC\Authentication\WebAuthn\Manager as WebAuthnManager;
use OC\Security\Bruteforce\Throttler;
use OC\User\Session;
use OC_App;
-use OC_Util;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -150,7 +149,7 @@ class LoginController extends Controller {
*/
public function showLoginForm(string $user = null, string $redirect_url = null): Http\Response {
if ($this->userSession->isLoggedIn()) {
- return new RedirectResponse(OC_Util::getDefaultPageUrl());
+ return new RedirectResponse($this->urlGenerator->linkToDefaultPageUrl());
}
$loginMessages = $this->session->get('loginMessages');
@@ -274,7 +273,7 @@ class LoginController extends Controller {
return new RedirectResponse($location);
}
}
- return new RedirectResponse(OC_Util::getDefaultPageUrl());
+ return new RedirectResponse($this->urlGenerator->linkToDefaultPageUrl());
}
/**
diff --git a/core/Controller/RecommendedAppsController.php b/core/Controller/RecommendedAppsController.php
index 1b6650ed902..b38aaa31fca 100644
--- a/core/Controller/RecommendedAppsController.php
+++ b/core/Controller/RecommendedAppsController.php
@@ -30,15 +30,20 @@ use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\IInitialStateService;
use OCP\IRequest;
+use OCP\IURLGenerator;
class RecommendedAppsController extends Controller {
+ /** @var IURLGenerator */
+ public $urlGenerator;
/** @var IInitialStateService */
private $initialStateService;
public function __construct(IRequest $request,
+ IURLGenerator $urlGenerator,
IInitialStateService $initialStateService) {
parent::__construct('core', $request);
+ $this->urlGenerator = $urlGenerator;
$this->initialStateService = $initialStateService;
}
@@ -47,7 +52,8 @@ class RecommendedAppsController extends Controller {
* @return Response
*/
public function index(): Response {
- $this->initialStateService->provideInitialState('core', 'defaultPageUrl', \OC_Util::getDefaultPageUrl());
+ $defaultPageUrl = $this->urlGenerator->linkToDefaultPageUrl();
+ $this->initialStateService->provideInitialState('core', 'defaultPageUrl', $defaultPageUrl);
return new StandaloneTemplateResponse($this->appName, 'recommendedapps', [], 'guest');
}
}
diff --git a/core/Controller/SetupController.php b/core/Controller/SetupController.php
index 704a2507b5a..c89709012d1 100644
--- a/core/Controller/SetupController.php
+++ b/core/Controller/SetupController.php
@@ -119,12 +119,12 @@ class SetupController {
}
if ($installRecommended) {
- $urlGenerator = \OC::$server->getURLGenerator();
- $location = $urlGenerator->getAbsoluteURL('index.php/core/apps/recommended');
- header('Location: ' . $location);
+ header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
+ exit();
+ } else {
+ header('Location: ' . \OC::$server->getURLGenerator()->linkToDefaultPageUrl());
exit();
}
- \OC_Util::redirectToDefaultPage();
}
public function loadAutoConfig($post) {
diff --git a/core/Controller/TwoFactorChallengeController.php b/core/Controller/TwoFactorChallengeController.php
index 30f33230d8f..8f82346c050 100644
--- a/core/Controller/TwoFactorChallengeController.php
+++ b/core/Controller/TwoFactorChallengeController.php
@@ -27,7 +27,6 @@ namespace OC\Core\Controller;
use OC\Authentication\TwoFactorAuth\Manager;
use OC_User;
-use OC_Util;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\StandaloneTemplateResponse;
@@ -83,7 +82,7 @@ class TwoFactorChallengeController extends Controller {
protected function getLogoutUrl() {
return OC_User::getLogoutUrl($this->urlGenerator);
}
-
+
/**
* @param IProvider[] $providers
*/
@@ -203,7 +202,7 @@ class TwoFactorChallengeController extends Controller {
if (!is_null($redirect_url)) {
return new RedirectResponse($this->urlGenerator->getAbsoluteURL(urldecode($redirect_url)));
}
- return new RedirectResponse(OC_Util::getDefaultPageUrl());
+ return new RedirectResponse($this->urlGenerator->linkToDefaultPageUrl());
}
} catch (TwoFactorException $e) {
/*
diff --git a/core/Middleware/TwoFactorMiddleware.php b/core/Middleware/TwoFactorMiddleware.php
index 2ddfcafa027..fbdb106b7bb 100644
--- a/core/Middleware/TwoFactorMiddleware.php
+++ b/core/Middleware/TwoFactorMiddleware.php
@@ -31,6 +31,7 @@ use OC\Authentication\TwoFactorAuth\Manager;
use OC\Core\Controller\LoginController;
use OC\Core\Controller\TwoFactorChallengeController;
use OC\User\Session;
+use OCA\TwoFactorNextcloudNotification\Controller\APIController;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Middleware;
@@ -82,6 +83,11 @@ class TwoFactorMiddleware extends Middleware {
* @param string $methodName
*/
public function beforeController($controller, $methodName) {
+ if ($controller instanceof APIController && $methodName === 'poll') {
+ // Allow polling the twofactor nextcloud notifications state
+ return;
+ }
+
if ($controller instanceof TwoFactorChallengeController
&& $this->userSession->getUser() !== null
&& !$this->reflector->hasAnnotation('TwoFactorSetUpDoneRequired')) {
diff --git a/lib/base.php b/lib/base.php
index 45d06da0303..94610576fce 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -1021,12 +1021,10 @@ class OC {
OC_App::loadApps();
OC_User::setupBackends();
OC_Util::setupFS();
- // FIXME
- // Redirect to default application
- OC_Util::redirectToDefaultPage();
+ header('Location: ' . \OC::$server->getURLGenerator()->linkToDefaultPageUrl());
} else {
// Not handled and not logged in
- header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute('core.login.showLoginForm'));
+ header('Location: ' . \OC::$server->getURLGenerator()->linkToRouteAbsolute('core.login.showLoginForm'));
}
}
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index 511c37d2624..382179b23e0 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Daniel Rudolf <github.com@daniel-rudolf.de>
* @author Felix Epp <work@felixepp.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
@@ -45,6 +46,7 @@ use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
+use OCP\IUserSession;
use RuntimeException;
/**
@@ -53,6 +55,8 @@ use RuntimeException;
class URLGenerator implements IURLGenerator {
/** @var IConfig */
private $config;
+ /** @var IUserSession */
+ public $userSession;
/** @var ICacheFactory */
private $cacheFactory;
/** @var IRequest */
@@ -63,10 +67,12 @@ class URLGenerator implements IURLGenerator {
private $baseUrl = null;
public function __construct(IConfig $config,
+ IUserSession $userSession,
ICacheFactory $cacheFactory,
IRequest $request,
Router $router) {
$this->config = $config;
+ $this->userSession = $userSession;
$this->cacheFactory = $cacheFactory;
$this->request = $request;
$this->router = $router;
@@ -268,6 +274,49 @@ class URLGenerator implements IURLGenerator {
}
/**
+ * Returns the URL of the default page based on the system configuration
+ * and the apps visible for the current user
+ * @return string
+ */
+ public function linkToDefaultPageUrl(): string {
+ // Deny the redirect if the URL contains a @
+ // This prevents unvalidated redirects like ?redirect_url=:user@domain.com
+ if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) {
+ return $this->getAbsoluteURL(urldecode($_REQUEST['redirect_url']));
+ }
+
+ $defaultPage = $this->config->getAppValue('core', 'defaultpage');
+ if ($defaultPage) {
+ return $this->getAbsoluteURL($defaultPage);
+ }
+
+ $appId = 'files';
+ $defaultApps = explode(',', $this->config->getSystemValue('defaultapp', 'dashboard,files'));
+
+ $userId = $this->userSession->isLoggedIn() ? $this->userSession->getUser()->getUID() : null;
+ if ($userId !== null) {
+ $userDefaultApps = explode(',', $this->config->getUserValue($userId, 'core', 'defaultapp'));
+ $defaultApps = array_filter(array_merge($userDefaultApps, $defaultApps));
+ }
+
+ // find the first app that is enabled for the current user
+ foreach ($defaultApps as $defaultApp) {
+ $defaultApp = \OC_App::cleanAppId(strip_tags($defaultApp));
+ if (\OC::$server->getAppManager()->isEnabledForUser($defaultApp)) {
+ $appId = $defaultApp;
+ break;
+ }
+ }
+
+ if ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true
+ || getenv('front_controller_active') === 'true') {
+ return $this->getAbsoluteURL('/apps/' . $appId . '/');
+ }
+
+ return $this->getAbsoluteURL('/index.php/apps/' . $appId . '/');
+ }
+
+ /**
* @return string base url of the current request
*/
public function getBaseUrl(): string {
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index 333b621e359..35c81dd34e6 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -71,8 +71,8 @@ use OCP\Files\Template\ITemplateManager;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\ILogger;
+use OCP\IURLGenerator;
use OCP\IUser;
-use OCP\IUserSession;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
@@ -1090,46 +1090,9 @@ class OC_Util {
* @suppress PhanDeprecatedFunction
*/
public static function getDefaultPageUrl() {
- /** @var IConfig $config */
- $config = \OC::$server->get(IConfig::class);
- $urlGenerator = \OC::$server->getURLGenerator();
- // Deny the redirect if the URL contains a @
- // This prevents unvalidated redirects like ?redirect_url=:user@domain.com
- if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) {
- $location = $urlGenerator->getAbsoluteURL(urldecode($_REQUEST['redirect_url']));
- } else {
- $defaultPage = \OC::$server->getConfig()->getAppValue('core', 'defaultpage');
- if ($defaultPage) {
- $location = $urlGenerator->getAbsoluteURL($defaultPage);
- } else {
- $appId = 'files';
- $defaultApps = explode(',', $config->getSystemValue('defaultapp', 'dashboard,files'));
-
- /** @var IUserSession $userSession */
- $userSession = \OC::$server->get(IUserSession::class);
- $user = $userSession->getUser();
- if ($user) {
- $userDefaultApps = explode(',', $config->getUserValue($user->getUID(), 'core', 'defaultapp'));
- $defaultApps = array_filter(array_merge($userDefaultApps, $defaultApps));
- }
-
- // find the first app that is enabled for the current user
- foreach ($defaultApps as $defaultApp) {
- $defaultApp = OC_App::cleanAppId(strip_tags($defaultApp));
- if (static::getAppManager()->isEnabledForUser($defaultApp)) {
- $appId = $defaultApp;
- break;
- }
- }
-
- if ($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true') {
- $location = $urlGenerator->getAbsoluteURL('/apps/' . $appId . '/');
- } else {
- $location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/');
- }
- }
- }
- return $location;
+ /** @var IURLGenerator $urlGenerator */
+ $urlGenerator = \OC::$server->get(IURLGenerator::class);
+ return $urlGenerator->linkToDefaultPageUrl();
}
/**
diff --git a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php
index 36e629d6342..e957b245e53 100644
--- a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php
+++ b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php
@@ -26,18 +26,24 @@ declare(strict_types=1);
*/
namespace OCP\AppFramework\Http;
+use OCP\IURLGenerator;
+
/**
* Redirects to the default app
+ *
* @since 16.0.0
+ * @depreacted 23.0.0 Use RedirectResponse() with IURLGenerator::linkToDefaultPageUrl() instead
*/
class RedirectToDefaultAppResponse extends RedirectResponse {
-
-
/**
* Creates a response that redirects to the default app
+ *
* @since 16.0.0
+ * @depreacted 23.0.0 Use RedirectResponse() with IURLGenerator::linkToDefaultPageUrl() instead
*/
public function __construct() {
- parent::__construct(\OC_Util::getDefaultPageUrl());
+ /** @var IURLGenerator $urlGenerator */
+ $urlGenerator = \OC::$server->get(IURLGenerator::class);
+ parent::__construct($urlGenerator->linkToDefaultPageUrl());
}
}
diff --git a/lib/public/IURLGenerator.php b/lib/public/IURLGenerator.php
index 9f1a6447eb4..580536b8b5f 100644
--- a/lib/public/IURLGenerator.php
+++ b/lib/public/IURLGenerator.php
@@ -98,6 +98,14 @@ interface IURLGenerator {
public function linkToDocs(string $key): string;
/**
+ * Returns the URL of the default page based on the system configuration
+ * and the apps visible for the current user
+ * @return string
+ * @since 23.0.0
+ */
+ public function linkToDefaultPageUrl(): string;
+
+ /**
* @return string base url of the current request
* @since 13.0.0
*/
diff --git a/psalm.xml b/psalm.xml
index d51dbb9dde6..a075ceb24a7 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -80,6 +80,7 @@
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="OCA\GroupFolders\Mount\GroupFolderStorage"/>
+ <referencedClass name="OCA\TwoFactorNextcloudNotification\Controller\APIController"/>
</errorLevel>
</UndefinedClass>
<UndefinedFunction>
diff --git a/tests/Core/Command/Apps/AppsDisableTest.php b/tests/Core/Command/Apps/AppsDisableTest.php
index c6fcbf38b30..493dfc16f3e 100644
--- a/tests/Core/Command/Apps/AppsDisableTest.php
+++ b/tests/Core/Command/Apps/AppsDisableTest.php
@@ -55,31 +55,31 @@ class AppsDisableTest extends TestCase {
* @param $appId
* @param $groups
* @param $statusCode
- * @param $output
+ * @param $pattern
*/
- public function testCommandInput($appId, $statusCode, $output): void {
+ public function testCommandInput($appId, $statusCode, $pattern): void {
$input = ['app-id' => $appId];
$this->commandTester->execute($input);
- $this->assertStringContainsString($output, $this->commandTester->getDisplay());
+ $this->assertRegExp('/' . $pattern . '/', $this->commandTester->getDisplay());
$this->assertSame($statusCode, $this->commandTester->getStatusCode());
}
public function dataCommandInput(): array {
return [
- [['admin_audit'], 0, 'admin_audit 1.13.0 disabled'],
- [['comments'], 0, 'comments 1.13.0 disabled'],
+ [['admin_audit'], 0, 'admin_audit ([\d\.]*) disabled'],
+ [['comments'], 0, 'comments ([\d\.]*) disabled'],
[['invalid_app'], 0, 'No such app enabled: invalid_app'],
- [['admin_audit', 'comments'], 0, "admin_audit 1.13.0 disabled\ncomments 1.13.0 disabled"],
- [['admin_audit', 'comments', 'invalid_app'], 0, "admin_audit 1.13.0 disabled\ncomments 1.13.0 disabled\nNo such app enabled: invalid_app"],
+ [['admin_audit', 'comments'], 0, "admin_audit ([\d\.]*) disabled\ncomments ([\d\.]*) disabled"],
+ [['admin_audit', 'comments', 'invalid_app'], 0, "admin_audit ([\d\.]*) disabled\ncomments ([\d\.]*) disabled\nNo such app enabled: invalid_app"],
[['files'], 2, "files can't be disabled"],
[['provisioning_api'], 2, "provisioning_api can't be disabled"],
- [['files', 'admin_audit'], 2, "files can't be disabled.\nadmin_audit 1.13.0 disabled"],
- [['provisioning_api', 'comments'], 2, "provisioning_api can't be disabled.\ncomments 1.13.0 disabled"],
+ [['files', 'admin_audit'], 2, "files can't be disabled.\nadmin_audit ([\d\.]*) disabled"],
+ [['provisioning_api', 'comments'], 2, "provisioning_api can't be disabled.\ncomments ([\d\.]*) disabled"],
];
}
}
diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php
index 77d93668a49..73a7d3f449f 100644
--- a/tests/Core/Command/Apps/AppsEnableTest.php
+++ b/tests/Core/Command/Apps/AppsEnableTest.php
@@ -56,9 +56,9 @@ class AppsEnableTest extends TestCase {
* @param $appId
* @param $groups
* @param $statusCode
- * @param $output
+ * @param $pattern
*/
- public function testCommandInput($appId, $groups, $statusCode, $output): void {
+ public function testCommandInput($appId, $groups, $statusCode, $pattern): void {
$input = ['app-id' => $appId];
if (is_array($groups)) {
@@ -67,29 +67,29 @@ class AppsEnableTest extends TestCase {
$this->commandTester->execute($input);
- $this->assertStringContainsString($output, $this->commandTester->getDisplay());
+ $this->assertRegExp('/' . $pattern . '/', $this->commandTester->getDisplay());
$this->assertSame($statusCode, $this->commandTester->getStatusCode());
}
public function dataCommandInput(): array {
return [
- [['admin_audit'], null, 0, 'admin_audit 1.13.0 enabled'],
- [['comments'], null, 0, 'comments 1.13.0 enabled'],
- [['comments', 'comments'], null, 0, "comments 1.13.0 enabled\ncomments already enabled"],
+ [['admin_audit'], null, 0, 'admin_audit ([\d\.]*) enabled'],
+ [['comments'], null, 0, 'comments ([\d\.]*) enabled'],
+ [['comments', 'comments'], null, 0, "comments ([\d\.]*) enabled\ncomments already enabled"],
[['invalid_app'], null, 1, 'Could not download app invalid_app'],
- [['admin_audit', 'comments'], null, 0, "admin_audit 1.13.0 enabled\ncomments 1.13.0 enabled"],
- [['admin_audit', 'comments', 'invalid_app'], null, 1, "admin_audit 1.13.0 enabled\ncomments 1.13.0 enabled\nCould not download app invalid_app"],
+ [['admin_audit', 'comments'], null, 0, "admin_audit ([\d\.]*) enabled\ncomments ([\d\.]*) enabled"],
+ [['admin_audit', 'comments', 'invalid_app'], null, 1, "admin_audit ([\d\.]*) enabled\ncomments ([\d\.]*) enabled\nCould not download app invalid_app"],
[['admin_audit'], ['admin'], 1, "admin_audit can't be enabled for groups"],
[['comments'], ['admin'], 1, "comments can't be enabled for groups"],
- [['updatenotification'], ['admin'], 0, 'updatenotification 1.13.0 enabled for groups: admin'],
- [['updatenotification', 'accessibility'], ['admin'], 0, "updatenotification 1.13.0 enabled for groups: admin\naccessibility 1.9.0 enabled for groups: admin"],
+ [['updatenotification'], ['admin'], 0, 'updatenotification ([\d\.]*) enabled for groups: admin'],
+ [['updatenotification', 'accessibility'], ['admin'], 0, "updatenotification ([\d\.]*) enabled for groups: admin\naccessibility ([\d\.]*) enabled for groups: admin"],
- [['updatenotification'], ['admin', 'invalid_group'], 0, 'updatenotification 1.13.0 enabled for groups: admin'],
- [['updatenotification', 'accessibility'], ['admin', 'invalid_group'], 0, "updatenotification 1.13.0 enabled for groups: admin\naccessibility 1.9.0 enabled for groups: admin"],
- [['updatenotification', 'accessibility', 'invalid_app'], ['admin', 'invalid_group'], 1, "updatenotification 1.13.0 enabled for groups: admin\naccessibility 1.9.0 enabled for groups: admin\nCould not download app invalid_app"],
+ [['updatenotification'], ['admin', 'invalid_group'], 0, 'updatenotification ([\d\.]*) enabled for groups: admin'],
+ [['updatenotification', 'accessibility'], ['admin', 'invalid_group'], 0, "updatenotification ([\d\.]*) enabled for groups: admin\naccessibility ([\d\.]*) enabled for groups: admin"],
+ [['updatenotification', 'accessibility', 'invalid_app'], ['admin', 'invalid_group'], 1, "updatenotification ([\d\.]*) enabled for groups: admin\naccessibility ([\d\.]*) enabled for groups: admin\nCould not download app invalid_app"],
];
}
}
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php
index e3469621eec..fe42b55db15 100644
--- a/tests/Core/Controller/LoginControllerTest.php
+++ b/tests/Core/Controller/LoginControllerTest.php
@@ -211,8 +211,12 @@ class LoginControllerTest extends TestCase {
->expects($this->once())
->method('isLoggedIn')
->willReturn(true);
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDefaultPageUrl')
+ ->willReturn('/default/foo');
- $expectedResponse = new RedirectResponse(\OC_Util::getDefaultPageUrl());
+ $expectedResponse = new RedirectResponse('/default/foo');
$this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', '', ''));
}
@@ -443,7 +447,7 @@ class LoginControllerTest extends TestCase {
'direct' => 1,
])
->willReturn($loginPageUrl);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($loginPageUrl);
+ $expected = new RedirectResponse($loginPageUrl);
$expected->throttle(['user' => 'MyUserName']);
$response = $this->loginController->tryLogin($user, $password, '/apps/files');
@@ -454,7 +458,6 @@ class LoginControllerTest extends TestCase {
public function testLoginWithValidCredentials() {
$user = 'MyUserName';
$password = 'secret';
- $indexPageUrl = \OC_Util::getDefaultPageUrl();
$this->request
->expects($this->once())
@@ -470,11 +473,13 @@ class LoginControllerTest extends TestCase {
->method('process')
->with($this->equalTo($loginData))
->willReturn($loginResult);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($indexPageUrl);
-
- $response = $this->loginController->tryLogin($user, $password);
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDefaultPageUrl')
+ ->willReturn('/default/foo');
- $this->assertEquals($expected, $response);
+ $expected = new RedirectResponse('/default/foo');
+ $this->assertEquals($expected, $this->loginController->tryLogin($user, $password));
}
public function testLoginWithoutPassedCsrfCheckAndNotLoggedIn() {
@@ -498,8 +503,12 @@ class LoginControllerTest extends TestCase {
->method('deleteUserValue');
$this->userSession->expects($this->never())
->method('createRememberMeToken');
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDefaultPageUrl')
+ ->willReturn('/default/foo');
- $expected = new \OCP\AppFramework\Http\RedirectResponse(\OC_Util::getDefaultPageUrl());
+ $expected = new RedirectResponse('/default/foo');
$this->assertEquals($expected, $this->loginController->tryLogin('Jane', $password, $originalUrl));
}
@@ -534,14 +543,13 @@ class LoginControllerTest extends TestCase {
->with('remember_login_cookie_lifetime')
->willReturn(1234);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($redirectUrl);
+ $expected = new RedirectResponse($redirectUrl);
$this->assertEquals($expected, $this->loginController->tryLogin('Jane', $password, $originalUrl));
}
public function testLoginWithValidCredentialsAndRedirectUrl() {
$user = 'MyUserName';
$password = 'secret';
- $indexPageUrl = \OC_Util::getDefaultPageUrl();
$redirectUrl = 'https://next.cloud/apps/mail';
$this->request
@@ -566,7 +574,7 @@ class LoginControllerTest extends TestCase {
->method('getAbsoluteURL')
->with('/apps/mail')
->willReturn($redirectUrl);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($redirectUrl);
+ $expected = new RedirectResponse($redirectUrl);
$response = $this->loginController->tryLogin($user, $password, '/apps/mail');
@@ -601,7 +609,7 @@ class LoginControllerTest extends TestCase {
'direct' => 1,
])
->willReturn($loginPageUrl);
- $expected = new \OCP\AppFramework\Http\RedirectResponse($loginPageUrl);
+ $expected = new RedirectResponse($loginPageUrl);
$expected->throttle(['user' => 'john']);
$response = $this->loginController->tryLogin(
diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
index b899a1b236a..2cb8d4bd50f 100644
--- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php
+++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
@@ -25,7 +25,6 @@ namespace Test\Core\Controller;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Authentication\TwoFactorAuth\ProviderSet;
use OC\Core\Controller\TwoFactorChallengeController;
-use OC_Util;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin;
@@ -212,8 +211,12 @@ class TwoFactorChallengeControllerTest extends TestCase {
->method('verifyChallenge')
->with('myprovider', $user, 'token')
->willReturn(true);
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToDefaultPageUrl')
+ ->willReturn('/default/foo');
- $expected = new RedirectResponse(OC_Util::getDefaultPageUrl());
+ $expected = new RedirectResponse('/default/foo');
$this->assertEquals($expected, $this->controller->solveChallenge('myprovider', 'token'));
}
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php
index 761f4b42eea..9e5795fc41e 100644
--- a/tests/lib/UrlGeneratorTest.php
+++ b/tests/lib/UrlGeneratorTest.php
@@ -13,6 +13,8 @@ use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
+use OCP\IUser;
+use OCP\IUserSession;
/**
* Class UrlGeneratorTest
@@ -23,6 +25,8 @@ class UrlGeneratorTest extends \Test\TestCase {
/** @var \PHPUnit\Framework\MockObject\MockObject|IConfig */
private $config;
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IUserSession */
+ private $userSession;
/** @var \PHPUnit\Framework\MockObject\MockObject|ICacheFactory */
private $cacheFactory;
/** @var \PHPUnit\Framework\MockObject\MockObject|IRequest */
@@ -37,11 +41,13 @@ class UrlGeneratorTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
+ $this->userSession = $this->createMock(IUserSession::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->request = $this->createMock(IRequest::class);
$this->router = $this->createMock(Router::class);
$this->urlGenerator = new \OC\URLGenerator(
$this->config,
+ $this->userSession,
$this->cacheFactory,
$this->request,
$this->router
@@ -210,4 +216,109 @@ class UrlGeneratorTest extends \Test\TestCase {
['core.WhatsNew.dismiss', 'http://localhost/nextcloud/ocs/v2.php/core/whatsnew'],
];
}
+
+ private function mockLinkToDefaultPageUrl(string $defaultAppConfig = '', bool $ignoreFrontControllerConfig = false) {
+ $this->config->expects($this->exactly(2))
+ ->method('getSystemValue')
+ ->withConsecutive(
+ ['defaultapp', $this->anything()],
+ ['htaccess.IgnoreFrontController', $this->anything()],
+ )
+ ->will($this->onConsecutiveCalls(
+ $defaultAppConfig,
+ $ignoreFrontControllerConfig
+ ));
+ $this->config->expects($this->once())
+ ->method('getAppValue')
+ ->with('core', 'defaultpage')
+ ->willReturn('');
+ }
+
+ public function testLinkToDefaultPageUrlWithRedirectUrlWithoutFrontController() {
+ $this->mockBaseUrl();
+
+ $_REQUEST['redirect_url'] = 'myRedirectUrl.com';
+ $this->assertSame('http://localhost' . \OC::$WEBROOT . '/myRedirectUrl.com', $this->urlGenerator->linkToDefaultPageUrl());
+ }
+
+ public function testLinkToDefaultPageUrlWithRedirectUrlRedirectBypassWithoutFrontController() {
+ $this->mockBaseUrl();
+ $this->mockLinkToDefaultPageUrl();
+ putenv('front_controller_active=false');
+
+ $_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
+ $this->assertSame('http://localhost' . \OC::$WEBROOT . '/index.php/apps/files/', $this->urlGenerator->linkToDefaultPageUrl());
+ }
+
+ public function testLinkToDefaultPageUrlWithRedirectUrlRedirectBypassWithFrontController() {
+ $this->mockBaseUrl();
+ $this->mockLinkToDefaultPageUrl();
+ putenv('front_controller_active=true');
+
+ $_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
+ $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/files/', $this->urlGenerator->linkToDefaultPageUrl());
+ }
+
+ public function testLinkToDefaultPageUrlWithRedirectUrlWithIgnoreFrontController() {
+ $this->mockBaseUrl();
+ $this->mockLinkToDefaultPageUrl('', true);
+ putenv('front_controller_active=false');
+
+ $_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
+ $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/files/', $this->urlGenerator->linkToDefaultPageUrl());
+ }
+
+ /**
+ * @dataProvider provideDefaultApps
+ */
+ public function testLinkToDefaultPageUrlWithDefaultApps($defaultAppConfig, $expectedPath) {
+ $userId = $this->getUniqueID();
+
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IUser $userMock */
+ $userMock = $this->createMock(IUser::class);
+ $userMock->expects($this->once())
+ ->method('getUID')
+ ->willReturn($userId);
+
+ $this->mockBaseUrl();
+ $this->mockLinkToDefaultPageUrl($defaultAppConfig);
+
+ $this->config->expects($this->once())
+ ->method('getUserValue')
+ ->with($userId, 'core', 'defaultapp')
+ ->willReturn('');
+ $this->userSession->expects($this->once())
+ ->method('isLoggedIn')
+ ->willReturn(true);
+ $this->userSession->expects($this->once())
+ ->method('getUser')
+ ->willReturn($userMock);
+
+ $this->assertEquals('http://localhost' . \OC::$WEBROOT . $expectedPath, $this->urlGenerator->linkToDefaultPageUrl());
+ }
+
+ public function provideDefaultApps() {
+ return [
+ // none specified, default to files
+ [
+ '',
+ '/index.php/apps/files/',
+ ],
+ // unexisting or inaccessible app specified, default to files
+ [
+ 'unexist',
+ '/index.php/apps/files/',
+ ],
+ // non-standard app
+ [
+ 'settings',
+ '/index.php/apps/settings/',
+ ],
+ // non-standard app with fallback
+ [
+ 'unexist,settings',
+ '/index.php/apps/settings/',
+ ],
+ ];
+ }
}
diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php
index e21a5323b1b..04d4858fb26 100644
--- a/tests/lib/UtilTest.php
+++ b/tests/lib/UtilTest.php
@@ -9,7 +9,6 @@
namespace Test;
use OC_Util;
-use OCP\App\IAppManager;
/**
* Class UtilTest
@@ -170,96 +169,6 @@ class UtilTest extends \Test\TestCase {
}
/**
- * Test default apps
- *
- * @dataProvider defaultAppsProvider
- * @group DB
- */
- public function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps) {
- $oldDefaultApps = \OC::$server->getConfig()->getSystemValue('defaultapp', '');
- // CLI is doing messy stuff with the webroot, so need to work it around
- $oldWebRoot = \OC::$WEBROOT;
- \OC::$WEBROOT = '';
-
- $appManager = $this->createMock(IAppManager::class);
- $appManager->expects($this->any())
- ->method('isEnabledForUser')
- ->willReturnCallback(function ($appId) use ($enabledApps) {
- return in_array($appId, $enabledApps);
- });
- Dummy_OC_Util::$appManager = $appManager;
-
- // need to set a user id to make sure enabled apps are read from cache
- \OC_User::setUserId($this->getUniqueID());
- \OC::$server->getConfig()->setSystemValue('defaultapp', $defaultAppConfig);
- $this->assertEquals('http://localhost/' . $expectedPath, Dummy_OC_Util::getDefaultPageUrl());
-
- // restore old state
- \OC::$WEBROOT = $oldWebRoot;
- \OC::$server->getConfig()->setSystemValue('defaultapp', $oldDefaultApps);
- \OC_User::setUserId(null);
- }
-
- public function defaultAppsProvider() {
- return [
- // none specified, default to files
- [
- '',
- 'index.php/apps/files/',
- ['files'],
- ],
- // unexisting or inaccessible app specified, default to files
- [
- 'unexist',
- 'index.php/apps/files/',
- ['files'],
- ],
- // non-standard app
- [
- 'calendar',
- 'index.php/apps/calendar/',
- ['files', 'calendar'],
- ],
- // non-standard app with fallback
- [
- 'contacts,calendar',
- 'index.php/apps/calendar/',
- ['files', 'calendar'],
- ],
- ];
- }
-
- public function testGetDefaultPageUrlWithRedirectUrlWithoutFrontController() {
- putenv('front_controller_active=false');
- \OC::$server->getConfig()->deleteSystemValue('htaccess.IgnoreFrontController');
-
- $_REQUEST['redirect_url'] = 'myRedirectUrl.com';
- $this->assertSame('http://localhost'.\OC::$WEBROOT.'/myRedirectUrl.com', OC_Util::getDefaultPageUrl());
- }
-
- public function testGetDefaultPageUrlWithRedirectUrlRedirectBypassWithoutFrontController() {
- putenv('front_controller_active=false');
- \OC::$server->getConfig()->deleteSystemValue('htaccess.IgnoreFrontController');
-
- $_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
- $this->assertSame('http://localhost'.\OC::$WEBROOT.'/index.php/apps/files/', OC_Util::getDefaultPageUrl());
- }
-
- public function testGetDefaultPageUrlWithRedirectUrlRedirectBypassWithFrontController() {
- putenv('front_controller_active=true');
- $_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
- $this->assertSame('http://localhost'.\OC::$WEBROOT.'/apps/files/', OC_Util::getDefaultPageUrl());
- }
-
- public function testGetDefaultPageUrlWithRedirectUrlWithIgnoreFrontController() {
- putenv('front_controller_active=false');
- \OC::$server->getConfig()->setSystemValue('htaccess.IgnoreFrontController', true);
-
- $_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
- $this->assertSame('http://localhost'.\OC::$WEBROOT.'/apps/files/', OC_Util::getDefaultPageUrl());
- }
-
- /**
* Test needUpgrade() when the core version is increased
*/
public function testNeedUpgradeCore() {
@@ -390,17 +299,3 @@ class UtilTest extends \Test\TestCase {
], \OC_Util::$styles);
}
}
-
-/**
- * Dummy OC Util class to make it possible to override the app manager
- */
-class Dummy_OC_Util extends OC_Util {
- /**
- * @var \OCP\App\IAppManager
- */
- public static $appManager;
-
- protected static function getAppManager() {
- return self::$appManager;
- }
-}