public bool CheckAddIP(string code) { IPVerificationContext db = new IPVerificationContext(); var verification = from profile in db.IPVerificationEntries where profile.Code == code select profile; if (verification != null) { IPVerificationModel IPVerification = verification.ToArray().First(); CustSecurityContext dbNew = new CustSecurityContext(); IPProfile newProfile = new IPProfile(IPVerification.Username, IPVerification.IP); dbNew.IPProfiles.Add(newProfile); dbNew.SaveChanges(); db.IPVerificationEntries.Remove(IPVerification); db.SaveChanges(); return true; } return false; }
public void createIPVerification(IPProfile ipProfile) { //Insert your domain here to be able to send correct email verification //Insert it like this: http://www.yourname.com string hostAdress = ""; IPVerificationContext db = new IPVerificationContext(); string validationString; for (int i = 0; true; i++) { validationString = GenerateCode(); var codes = from profile in db.IPVerificationEntries select profile.Code; string[] codeArray = codes.ToArray(); if (!codeArray.Contains(validationString)) { break; } } IPVerificationModel verification = new IPVerificationModel(ipProfile.Username, ipProfile.IP, validationString); db.IPVerificationEntries.Add(verification); db.SaveChanges(); if (hostAdress != "") { MailController.SendMailInner(ipProfile.Username, "IP verificatie", "Hallo, er is geprobeert om op uw account in te loggen vanaf een IP dat niet eerder hiervoor is gebruikt. Als u dit was kunt u op de link hieronder klikken. Was u dit niet, dan hoeft u niks te doen. " + hostAdress + "/test/" + validationString); } }