From 87ace12a4f06ab1d147abd58fb6d961c550dd755 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 7 Nov 2017 13:49:02 +0100 Subject: [PATCH 01/11] Prevent double clicks of the Save button U4-10646 Sorting nodes in edge cases can lead to blanking out of property data --- src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js b/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js index dc74ad95ff..3de038c859 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js +++ b/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js @@ -105,6 +105,7 @@ //wire up the submit button self._opts.submitButton.click(function() { + this.disabled = true; self._saveSort(); }); From 51fec0c7d3114ffce9cbea8648018d8bbe3703dc Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 7 Nov 2017 14:03:17 +0100 Subject: [PATCH 02/11] Remove misleading text, nothing bad will happen when you close the sort panel, sorting is a background task. --- src/Umbraco.Web.UI/Umbraco/config/lang/cs.xml | 2 +- src/Umbraco.Web.UI/Umbraco/config/lang/nb.xml | 2 +- src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/da.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/de.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/en.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/es.xml | 3 +-- src/Umbraco.Web.UI/umbraco/config/lang/fr.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/he.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/it.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/ja.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/ko.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/nl.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/pl.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/pt.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/ru.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/sv.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/tr.xml | 2 +- src/Umbraco.Web.UI/umbraco/config/lang/zh.xml | 2 +- 20 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/cs.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/cs.xml index 5ca5078e72..d01ccf8af9 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/cs.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/cs.xml @@ -781,7 +781,7 @@ Creation date Třídění bylo ukončeno. Abyste nastavili, jak mají být položky seřazeny, přetáhněte jednotlivé z nich nahoru či dolů. Anebo klikněte na hlavičku sloupce pro setřídění celé kolekce -
Během třídění nezavírejte toto okno]]>
+ Publikování bylo zrušeno doplňkem třetí strany diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/nb.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/nb.xml index c6c6093395..2b60f3ea17 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/nb.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/nb.xml @@ -736,7 +736,7 @@ Vennlig hilsen Umbraco roboten Creation date Sortering ferdig. Dra elementene opp eller ned for å arrangere dem. Du kan også klikke kolonneoverskriftene for å sortere alt på en gang. -
Ikke lukk dette vinduet under sortering]]>
+ En feil oppsto diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml index 53e893ea23..58b0522e02 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/zh_tw.xml @@ -912,7 +912,7 @@ 增添時間 排序完成。 上下拖拽項目或按一下列頭進行排序 -
排序中請不要關閉視窗。]]>
+ 驗證 diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml index d64e8b82ed..b855b26bef 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml @@ -964,7 +964,7 @@ Mange hilsner fra Umbraco robotten Oprettelsesdato Sortering udført Træk de forskellige sider op eller ned for at indstille hvordan de skal arrangeres, eller klik på kolonnehovederne for at sortere hele rækken af sider -
Luk ikke dette vindue imens]]>
+ Annulleret diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/de.xml b/src/Umbraco.Web.UI/umbraco/config/lang/de.xml index 3e610e87e2..f20a88a22a 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/de.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/de.xml @@ -773,7 +773,7 @@ Wenn Sie sich für Runway entscheiden, können Sie optional Blöcke nutzen, die Erstellungsdatum Sortierung abgeschlossen. Ziehen Sie die Elemente an ihre gewünschte neue Position. - Bitte warten, die Seiten werden sortiert. Das kann einen Moment dauern. Bitte schließen Sie dieses Fenster nicht, bis der Sortiervorgang abgeschlossen ist. + Bitte warten, die Seiten werden sortiert. Das kann einen Moment dauern. Fehlgeschlagen diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index 4169c88335..3a0b064cfc 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -1038,7 +1038,7 @@ To manage your website, simply open the Umbraco back office and start adding con Creation date Sorting complete. Drag the different items up or down below to set how they should be arranged. Or click the column headers to sort the entire collection of items -
Do not close this window during sorting]]>
+ Validation diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index 13e0ebdad5..e88667e4ab 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -1097,7 +1097,7 @@ To manage your website, simply open the Umbraco back office and start adding con Creation date Sorting complete. Drag the different items up or down below to set how they should be arranged. Or click the column headers to sort the entire collection of items -
Do not close this window during sorting]]>
+ Validation diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/es.xml b/src/Umbraco.Web.UI/umbraco/config/lang/es.xml index 9e813f136c..7152a1ebf0 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/es.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/es.xml @@ -688,8 +688,7 @@ Creation date Ordenación completa. Arrastra las diferentes páginas debajo para colocarlas como deberían estar. O haz click en las cabeceras de las columnas para ordenar todas las páginas - -
No cierre esta ventana mientras se está ordenando ]]>
+ La publicación fue cancelada por un complemento de terceros diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/fr.xml b/src/Umbraco.Web.UI/umbraco/config/lang/fr.xml index 838e605483..94254d8a33 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/fr.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/fr.xml @@ -1026,7 +1026,7 @@ Pour gérer votre site, ouvrez simplement le backoffice Umbraco et commencez à Date de création Tri achevé. Faites glisser les différents éléments vers le haut ou vers le bas pour définir la manière dont ils doivent être organisés. Ou cliquez sur les entêtes de colonnes pour trier la collection complète d'éléments -
Ne fermez pas cette fenêtre durant le tri.]]>
+ Validation diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/he.xml b/src/Umbraco.Web.UI/umbraco/config/lang/he.xml index a99066ed24..d53bf50543 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/he.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/he.xml @@ -693,7 +693,7 @@ To manage your website, simply open the Umbraco back office and start adding con Creation date המיון הושלם. יש לגרור את הפריטים מעלה או מטה כדי להגדיר את סדר התוכן. או לחץ על כותרת העמודה כדי למיין את כל פריטי התוכן -
נא לא לסגור את החלון בזמן המיון]]>
+ הפירסום בוטל על ידי תוסף צד שלישי diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/it.xml b/src/Umbraco.Web.UI/umbraco/config/lang/it.xml index 865703e213..415503e53a 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/it.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/it.xml @@ -659,7 +659,7 @@ Per gestire il tuo sito web, è sufficiente aprire il back office di Umbraco e i Creation date -
Non chiudere questa finestra durante l'operazione]]>
+ diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/ja.xml b/src/Umbraco.Web.UI/umbraco/config/lang/ja.xml index 21417dfbcb..319a746cc5 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/ja.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/ja.xml @@ -898,7 +898,7 @@ Runwayをインストールして作られた新しいウェブサイトがど Creation date ソートが完了しました。 上下にアイテムをドラッグするなどして適当に配置したり、列のヘッダーをクリックしてコレクション全体をソートできます -
並び替え中はウィンドウを閉じないでください。]]>
+ 検証 diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/ko.xml b/src/Umbraco.Web.UI/umbraco/config/lang/ko.xml index ee9be97c71..d1c1f43861 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/ko.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/ko.xml @@ -669,7 +669,7 @@ Creation date 정렬 완료 다른 아이템을 마우스로 위,아래로 드래그 하여 이동하거나 열의 헤더를 클릭하여 아이템을 정렬할 수 있습니다 -
정렬하는 동안 이 창을 닫지 마십시오]]>
+ 3rd party add-in 때문에 발행이 취소되었습니다. diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/nl.xml b/src/Umbraco.Web.UI/umbraco/config/lang/nl.xml index 2ddc4851dc..7d3dcaaf2b 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/nl.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/nl.xml @@ -954,7 +954,7 @@ Echter, Runway biedt een gemakkelijke basis om je snel op weg te helpen. Als je Creation date Sorteren gereed. Sleep de pagina's omhoog of omlaag om de volgorde te veranderen. Of klik op de kolom-header om alle pagina's daarop te sorteren. -
Sluit dit venster niet tijdens het sorteren]]>
+ Validatie diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/pl.xml b/src/Umbraco.Web.UI/umbraco/config/lang/pl.xml index 89d39dc659..a0eb96b95d 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/pl.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/pl.xml @@ -1025,7 +1025,7 @@ Naciśnij przycisk instaluj, aby zainstalować bazę danych Umb Data utworzenia Sortowanie zakończone. Przesuń poszczególne elementy w górę oraz w dół aż będą w odpowiedniej kolejności lub kliknij na nagłówku kolumny, aby posortować całą kolekcję elementów -
Nie zamykaj tego okna podczas sortowania]]>
+ Walidacja diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/pt.xml b/src/Umbraco.Web.UI/umbraco/config/lang/pt.xml index 1953dac8f8..ede1566b19 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/pt.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/pt.xml @@ -658,7 +658,7 @@ Você pode publicar esta página e todas suas sub-páginas ao selecionar pub Creation date Classificação concluída. Arraste os diferentes itens para cima ou para baixo para definir como os mesmos serão arranjados. Ou clique no título da coluna para classificar a coleção completa de itens -
Não feche esta janela durante a classificação]]>
+ Publicação foi cancelada por add-in de terceiros diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/ru.xml b/src/Umbraco.Web.UI/umbraco/config/lang/ru.xml index 228b549261..dc56899f6f 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/ru.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/ru.xml @@ -1243,7 +1243,7 @@ Дата создания Сортировка завершена Перетаскивайте элементы на нужное место вверх или вниз для определения необходимого Вам порядка сортировки. Также можно использовать заголовки столбцов, чтобы отсортировать все элементы сразу. -
Не закрывайте это окно до окончания процесса сортировки.]]>
+ Процесс публикации был отменен установленным пакетом дополнений. diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/sv.xml b/src/Umbraco.Web.UI/umbraco/config/lang/sv.xml index 17bc3ee5d0..3206d8a9b6 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/sv.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/sv.xml @@ -697,7 +697,7 @@ Creation date Sortering klar Välj i vilken ordning du vill ha sidorna genom att dra dem upp eller ner i listan. Du kan också klicka på kolumnrubrikerna för att sortera grupper av sidor -
Stäng inte fönstret under tiden sidorna sorteras.]]>
+ Publiceringen avbröts av ett tredjepartstillägg diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/tr.xml b/src/Umbraco.Web.UI/umbraco/config/lang/tr.xml index 2d32cb6d0b..cefd4d7a15 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/tr.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/tr.xml @@ -855,7 +855,7 @@ To manage your website, simply open the Umbraco back office and start adding con Sorting complete. Drag the different items up or down below to set how they should be arranged. Or click the column headers to sort the entire collection of items -
Do not close this window during sorting]]>
+ Hata diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/zh.xml b/src/Umbraco.Web.UI/umbraco/config/lang/zh.xml index 55a01d299e..22e33960aa 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/zh.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/zh.xml @@ -1080,7 +1080,7 @@ 创建日期 排序完成。 上下拖拽项目或单击列头进行排序 -
请不要关闭窗口]]>
+ 验证 From 0b904e82b55e735f1a0de672b7d49ed34a06374b Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 7 Nov 2017 16:36:15 +0100 Subject: [PATCH 03/11] Get user by id instead of loginname U4-9857 Umbraco 7.6 - Exception after changing user login name --- .../Security/MembershipProviderExtensions.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Security/MembershipProviderExtensions.cs b/src/Umbraco.Core/Security/MembershipProviderExtensions.cs index 645de22ab8..85cc8dd814 100644 --- a/src/Umbraco.Core/Security/MembershipProviderExtensions.cs +++ b/src/Umbraco.Core/Security/MembershipProviderExtensions.cs @@ -37,11 +37,15 @@ namespace Umbraco.Core.Security var identity = Thread.CurrentPrincipal.GetUmbracoIdentity(); if (identity != null) { - var user = userService.GetByUsername(identity.Username); - var userIsAdmin = user.IsAdmin(); - if (userIsAdmin) + var userId = 0; + if(int.TryParse(identity.Id.ToString(), out userId)) { - canReset = true; + var user = userService.GetUserById(userId); + var userIsAdmin = user.IsAdmin(); + if (userIsAdmin) + { + canReset = true; + } } } } From 9a94ac5317f96ac406552300df1937608e98cdc9 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 7 Nov 2017 16:51:40 +0100 Subject: [PATCH 04/11] Implement TwoFactorSignInAsync from Identity repo to make sure our custom GetVerifiedUserIdAsync fires U4-10620 Umbraco 2FA implementation issues --- .../Security/BackOfficeSignInManager.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/Umbraco.Core/Security/BackOfficeSignInManager.cs b/src/Umbraco.Core/Security/BackOfficeSignInManager.cs index 3c0057bcb5..2e20f37125 100644 --- a/src/Umbraco.Core/Security/BackOfficeSignInManager.cs +++ b/src/Umbraco.Core/Security/BackOfficeSignInManager.cs @@ -250,5 +250,42 @@ namespace Umbraco.Core.Security } return null; } + + /// + /// + /// Two factor verification step + /// + /// + /// + /// + /// + /// + public override async Task TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberBrowser) + { + var userId = await GetVerifiedUserIdAsync(); + if (userId == null) + { + return SignInStatus.Failure; + } + var user = await UserManager.FindByIdAsync(userId); + if (user == null) + { + return SignInStatus.Failure; + } + if (await UserManager.IsLockedOutAsync(user.Id)) + { + return SignInStatus.LockedOut; + } + if (await UserManager.VerifyTwoFactorTokenAsync(user.Id, provider, code)) + { + // When token is verified correctly, clear the access failed count used for lockout + await UserManager.ResetAccessFailedCountAsync(user.Id); + await SignInAsync(user, isPersistent, rememberBrowser); + return SignInStatus.Success; + } + // If the token is incorrect, record the failure which also may cause the user to be locked out + await UserManager.AccessFailedAsync(user.Id); + return SignInStatus.Failure; + } } } \ No newline at end of file From b1ceeb23b3318871bf22717e9c2fe1d1961cef50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Knippers?= Date: Thu, 2 Nov 2017 15:06:35 +0100 Subject: [PATCH 05/11] Only show characters left is a number of characters is configured on the datatype, hide otherwise --- .../propertyeditors/textbox/textbox.controller.js | 14 +++++++++++--- .../src/views/propertyeditors/textbox/textbox.html | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js index 2d0515d764..734903e46c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js @@ -5,12 +5,20 @@ function textboxController($scope) { $scope.model.config = {}; } + $scope.model.maxlength = false; + if ($scope.model.config && $scope.model.config.maxChars) { + $scope.model.maxlength = true; + } + if (!$scope.model.config.maxChars) { + // 500 is the maximum number that can be stored + // in the database, so set it to the max, even + // if no max is specified in the config $scope.model.config.maxChars = 500; } - if ($scope.model.config && $scope.model.config.maxChars) { - if ($scope.model.value == undefined) { + if ($scope.model.maxlength) { + if ($scope.model.value === undefined) { $scope.model.count = ($scope.model.config.maxChars * 1); } else { $scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length; @@ -19,7 +27,7 @@ function textboxController($scope) { $scope.model.change = function () { if ($scope.model.config && $scope.model.config.maxChars) { - if ($scope.model.value == undefined) { + if ($scope.model.value === undefined) { $scope.model.count = ($scope.model.config.maxChars * 1); } else { $scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html index a386bd38b9..77656ac618 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html @@ -7,7 +7,7 @@ ng-keyup="model.change()" /> Required -
+
{{model.count}} characters left
From 2538e2e9c9950d11a7444e9d7cac12444a1ce16c Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Nov 2017 16:06:23 +1100 Subject: [PATCH 06/11] additional null check --- .../Security/MembershipProviderExtensions.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Security/MembershipProviderExtensions.cs b/src/Umbraco.Core/Security/MembershipProviderExtensions.cs index 85cc8dd814..ad39efdc06 100644 --- a/src/Umbraco.Core/Security/MembershipProviderExtensions.cs +++ b/src/Umbraco.Core/Security/MembershipProviderExtensions.cs @@ -37,14 +37,18 @@ namespace Umbraco.Core.Security var identity = Thread.CurrentPrincipal.GetUmbracoIdentity(); if (identity != null) { + //get the user id from the identity var userId = 0; if(int.TryParse(identity.Id.ToString(), out userId)) { var user = userService.GetUserById(userId); - var userIsAdmin = user.IsAdmin(); - if (userIsAdmin) + if (user != null) { - canReset = true; + var userIsAdmin = user.IsAdmin(); + if (userIsAdmin) + { + canReset = true; + } } } } From 95f632e1eac742a053c08d597c224d2d22d59ed3 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Nov 2017 17:16:11 +1100 Subject: [PATCH 07/11] Adds notes and overrides SendTwoFactorCodeAsync and checks for -1 instead of null --- .../Security/BackOfficeSignInManager.cs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Security/BackOfficeSignInManager.cs b/src/Umbraco.Core/Security/BackOfficeSignInManager.cs index 2e20f37125..870ed9452c 100644 --- a/src/Umbraco.Core/Security/BackOfficeSignInManager.cs +++ b/src/Umbraco.Core/Security/BackOfficeSignInManager.cs @@ -12,6 +12,7 @@ using Umbraco.Core.Models.Identity; namespace Umbraco.Core.Security { + //TODO: In v8 we need to change this to use an int? nullable TKey instead, see notes against overridden TwoFactorSignInAsync public class BackOfficeSignInManager : SignInManager { private readonly ILogger _logger; @@ -251,7 +252,6 @@ namespace Umbraco.Core.Security return null; } - /// /// /// Two factor verification step /// @@ -260,10 +260,16 @@ namespace Umbraco.Core.Security /// /// /// + /// + /// This is implemented because we cannot override GetVerifiedUserIdAsync and instead we have to shadow it + /// so due to this and because we are using an INT as the TKey and not an object, it can never be null. Adding to that + /// the default(int) value returned by the base class is always a valid user (i.e. the admin) so we just have to duplicate + /// all of this code to check for -1 instead. + /// public override async Task TwoFactorSignInAsync(string provider, string code, bool isPersistent, bool rememberBrowser) { var userId = await GetVerifiedUserIdAsync(); - if (userId == null) + if (userId == -1) { return SignInStatus.Failure; } @@ -287,5 +293,25 @@ namespace Umbraco.Core.Security await UserManager.AccessFailedAsync(user.Id); return SignInStatus.Failure; } + + /// Send a two factor code to a user + /// + /// + /// + /// This is implemented because we cannot override GetVerifiedUserIdAsync and instead we have to shadow it + /// so due to this and because we are using an INT as the TKey and not an object, it can never be null. Adding to that + /// the default(int) value returned by the base class is always a valid user (i.e. the admin) so we just have to duplicate + /// all of this code to check for -1 instead. + /// + public override async Task SendTwoFactorCodeAsync(string provider) + { + var userId = await GetVerifiedUserIdAsync(); + if (userId == -1) + return false; + + var token = await UserManager.GenerateTwoFactorTokenAsync(userId, provider); + var identityResult = await UserManager.NotifyTwoFactorTokenAsync(userId, provider, token); + return identityResult.Succeeded; + } } } \ No newline at end of file From 016caba35f7b32b47201fe9255d3f3462368c702 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Nov 2017 17:47:18 +1100 Subject: [PATCH 08/11] attempt to fix tests --- src/Umbraco.Tests/UdiTests.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Umbraco.Tests/UdiTests.cs b/src/Umbraco.Tests/UdiTests.cs index 75f4536fd4..f1c232d697 100644 --- a/src/Umbraco.Tests/UdiTests.cs +++ b/src/Umbraco.Tests/UdiTests.cs @@ -13,6 +13,12 @@ namespace Umbraco.Tests [TestFixture] public class UdiTests { + [SetUp] + public void Setup() + { + Udi.ResetUdiTypes(); + } + [Test] public void StringUdiCtorTest() { From 8959b81f6a1ef05adb42e3c0e17c45ee99676dbc Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Nov 2017 18:16:17 +1100 Subject: [PATCH 09/11] another test fix attempt (this is only for 7.6, this is already fixed in 7.7) --- src/Umbraco.Tests/UdiTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Tests/UdiTests.cs b/src/Umbraco.Tests/UdiTests.cs index f1c232d697..881bee870f 100644 --- a/src/Umbraco.Tests/UdiTests.cs +++ b/src/Umbraco.Tests/UdiTests.cs @@ -7,11 +7,12 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Deploy; using Umbraco.Core.Serialization; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests { [TestFixture] - public class UdiTests + public class UdiTests : BaseUmbracoApplicationTest { [SetUp] public void Setup() From 637abc384b2286914fcb990db40739a325607396 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Nov 2017 18:46:08 +1100 Subject: [PATCH 10/11] more test hacks --- src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs index 799c7c966b..f2a04c5f0f 100644 --- a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs +++ b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs @@ -20,8 +20,14 @@ using Umbraco.Web.Templates; namespace Umbraco.Tests.Web { [TestFixture] - public class TemplateUtilitiesTests + public class TemplateUtilitiesTests : BaseUmbracoApplicationTest { + [SetUp] + public void Setup() + { + Udi.ResetUdiTypes(); + } + [TestCase("", "")] [TestCase("hello href=\"{localLink:1234}\" world ", "hello href=\"/my-test-url\" world ")] [TestCase("hello href=\"{localLink:umb://document-type/9931BDE0-AAC3-4BAB-B838-909A7B47570E}\" world ", "hello href=\"/my-test-url\" world ")] From 977b30c51a3c14e15c7ca10ae15fb7cd20ca120a Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Nov 2017 19:23:34 +1100 Subject: [PATCH 11/11] Revert "more test hacks" which in theory shouldn't be required for 7.7+ --- src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs index f2a04c5f0f..799c7c966b 100644 --- a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs +++ b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs @@ -20,14 +20,8 @@ using Umbraco.Web.Templates; namespace Umbraco.Tests.Web { [TestFixture] - public class TemplateUtilitiesTests : BaseUmbracoApplicationTest + public class TemplateUtilitiesTests { - [SetUp] - public void Setup() - { - Udi.ResetUdiTypes(); - } - [TestCase("", "")] [TestCase("hello href=\"{localLink:1234}\" world ", "hello href=\"/my-test-url\" world ")] [TestCase("hello href=\"{localLink:umb://document-type/9931BDE0-AAC3-4BAB-B838-909A7B47570E}\" world ", "hello href=\"/my-test-url\" world ")]