private bool ProcessToken(string userName, string token) { bool goodToken = false; IMemberShipData msd = new Data(Utility.GetAppSetting(BucketListConstants.DB_CONN)); User u = msd.GetUser(userName); if (u != null && !string.IsNullOrEmpty(u.Token) && !string.IsNullOrEmpty(token) && u.Token.Equals(token)) { byte[] data = Convert.FromBase64String(token); DateTime when = DateTime.FromBinary(BitConverter.ToInt64(data, 0)); if (when >= DateTime.UtcNow.AddHours(-2)) { goodToken = true; } } return goodToken; }
public string ProcessUser(string encodedUser, string encodedPass) { IMemberShipData msd = new Data(Utility.GetAppSetting(BucketListConstants.DB_CONN)); string token = string.Empty; try { string decodedUser = Utility.DecodeClientBase64String(encodedUser); string decodedPass = Utility.DecodeClientBase64String(encodedPass); LogProcessUserParameters(decodedUser, msd); token = VerifyUser(decodedUser, decodedPass, msd); if (!string.IsNullOrEmpty(token)) msd.AddToken(decodedUser, token); } catch (Exception e) { msd.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return token; }
public bool ProcessUserRegistration(string encodedUser, string encodedEmail, string encodedPass) { IMemberShipData msd = new Data(Utility.GetAppSetting(BucketListConstants.DB_CONN)); bool userAdded = false; try { string decodedUser = Utility.DecodeClientBase64String(encodedUser); string decodedEmail = Utility.DecodeClientBase64String(encodedEmail); string decodedPass = Utility.DecodeClientBase64String(encodedPass); IList<string> parameters = new List<string>(); parameters.Add(decodedUser); parameters.Add(decodedEmail); CommonCode.Log(msd, null, "ProcessUserRegistration", parameters); Password p = new Password(); NewPassword np = p.GetPassword(decodedPass); userAdded = msd.AddUser(decodedUser, decodedEmail, np.SaltedHashedPassword, np.Salt); } catch (Exception e) { msd.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return userAdded; }