/// <summary> /// Checks whether the user exists with given information. If a password /// is not provided and results false: the username exists in database. /// If a password is provided and results false: there was an information /// mismatch. /// /// Created by: Trent Cullinan 03/25/16 /// </summary> /// <param name="userName">Value to check database.</param> /// <param name="password">Value to check database.</param> /// <returns>Whether user has given correct information to be available.</returns> public bool ConfirmUserExists(string userName, string password = null) { bool flag = true; bool passwordFlag = String.IsNullOrEmpty(password); try { flag = passwordFlag ? UserAccessor.CheckUserName(userName) : UserAccessor.CheckUserNameWithPassword(userName, password.HashSha256()); } catch (Exception) { // If no password is sent in and an exception is caught, set to true // to signal that it is unavailable. // If a passsword is sent in and an exception is caught, set to false // to signal that nothing matched. flag = passwordFlag; } return(flag); }