When I'm trying this package everything works fine but after enabling 2FA when I click on another tab (eg. Media, Documents) in Umbraco back office then on the bottom showing two buttons, First one Discard and another Stay. When I press discard and then I checked in DB, successfully entry of user for 2FA in TwoFactor table. But in Umbraco back-office console showing an error or I'm getting a 500 error for TwoFactorEnabled API (Object reference not null).
public List<TwoFactorAuthInfo> TwoFactorEnabled(int userId = 0) { var database = DatabaseContext.Database; var user = Security.CurrentUser; userId = user != null ? user.Id : userId; var result = database.Fetch<TwoFactor>("WHERE [userId] = @userId AND [confirmed] = 1", new { userId }); var twoFactorAuthInfo = new List<TwoFactorAuthInfo>(); if (result.Any()) { foreach (var factor in result) { var authInfo = new TwoFactorAuthInfo { ApplicationName = factor.Key }; twoFactorAuthInfo.Add(authInfo); } } return twoFactorAuthInfo; }
When I'm trying this package everything works fine but after enabling 2FA when I click on another tab (eg. Media, Documents) in Umbraco back office then on the bottom showing two buttons, First one Discard and another Stay. When I press discard and then I checked in DB, successfully entry of user for 2FA in TwoFactor table. But in Umbraco back-office console showing an error or I'm getting a 500 error for TwoFactorEnabled API (Object reference not null).
public List<TwoFactorAuthInfo> TwoFactorEnabled(int userId = 0) { var database = DatabaseContext.Database; var user = Security.CurrentUser; userId = user != null ? user.Id : userId; var result = database.Fetch<TwoFactor>("WHERE [userId] = @userId AND [confirmed] = 1", new { userId }); var twoFactorAuthInfo = new List<TwoFactorAuthInfo>(); if (result.Any()) { foreach (var factor in result) { var authInfo = new TwoFactorAuthInfo { ApplicationName = factor.Key }; twoFactorAuthInfo.Add(authInfo); } } return twoFactorAuthInfo; }
I update this code and they work fine for me.