public static void SendUserCode(string email, GCTUser.Lang lang, bool SendEmail) { string body = ""; string subject = ""; if (lang == Lang.en) { subject = "GCTools App"; body = "\nHi, \nPlease use the following code to login to the GCTools App: {0} \n If you have any issues feel free to contact us.\n Thank you,\n The GCcollab Team.\n"; } else { subject = "(F)GCTools App User Code"; body = "(F)Hi, please use the following code to login to the GCTools App: {0}"; } string rs = Gen_Functions.RandomString(5); bool lan = (lang == GCTUser.Lang.en); SQLiteCommand cmd; int userid = UserID(email); if (userid == 0) { cmd = new SQLiteCommand("Insert into users (email, lasthit,firsthit,approved, logincode, loginattempts,langE) values(@email, @lasthit, @firsthit, 0, @code, 0,@langE)"); cmd.Parameters.AddWithValue("@firsthit", DateTime.Now); } else { cmd = new SQLiteCommand("update users set lasthit=@lasthit, logincode=@code, loginattempts=0, langE=@langE where email=@email"); } cmd.Parameters.AddWithValue("@lasthit", DateTime.Now); cmd.Parameters.AddWithValue("@email", email); cmd.Parameters.AddWithValue("@code", rs); cmd.Parameters.AddWithValue("@langE", lan); DBSQLite.ExecuteScalar(cmd); if (SendEmail) { Gen_Functions.SendMail(email, subject, string.Format(body, rs)); } }
public static void SendUserCode(string email, GCTUser.Lang lang) { SendUserCode(email, lang, true); }