//----------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Set Widget - add or update ... /// </summary> public static void SetWidget(PasswordResetWidget paw) { RemoveWidget(paw); lock (PasswordReset.Widgets) { Widgets.Add(paw); } }
//----------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Get Widget /// </summary> public static PasswordResetWidget GetWidget(int userID) { PasswordResetWidget paw = null; foreach (PasswordResetWidget tempPAW in Widgets) { if (tempPAW.UserID == userID) { paw = tempPAW; break; } } return(paw); }
//----------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Remove widget /// </summary> public static void RemoveWidget(PasswordResetWidget paw) { int index = -1; int i = 0; foreach (PasswordResetWidget tempPAW in Widgets) { if (tempPAW.UserID == paw.UserID) { index = i; break; } i++; } if (index >= 0) { lock (PasswordReset.Widgets) { Widgets.RemoveAt(index); } } }
//----------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Get Widget /// </summary> public static PasswordResetWidget GetWidget(StringBuilder guid) { PasswordResetWidget paw = null; if (guid != null && guid.Length > 0) { foreach (PasswordResetWidget tempPAW in Widgets) { // 17-Jul-15 - the MGLPasswordHash is overkill here, lets just use one level of encryption... //if (MGLPasswordHash.Compare( tempPAW.Guid, hashedGUID ) == true) { if (MGLEncryption.AreEqual(guid, tempPAW.Token) == true) { paw = tempPAW; break; } } } // random sleep to confuse on the checking if anyone is monitoring the timings!! Thread.Sleep(new Random().Next(0, 100)); return(paw); }