// method called to begin the process public void CheckEmailPassword() { Actor actor = Lib.GetByName(this.userName); //Actor actor = GetEmailInfo(); //get the email info for the user if (actor != null) { if (actor["email"].ToString() == "") { userSocket.SendLine("cannot send a new password to you in email because your account does not have an email address associated with it."); userSocket.SendLine("You'll have to contact the MUD admin for assistance at " + Lib.AdminEmail + ".\r\n"); return; } else { actor["email"] = RandomPasswordGenerator(); actor.Save(); this.MakeMailMessage(); this.SendEmail(); userSocket.SendLine("A new password was sent to your email address on file. Login with the new password to continue."); return; } } else { // No valid user account to reset the password for. // To prevent hackers fishing for valid accounts, spoof this. Lib.log.Add(this.userSocket, "trying username: "******"SECURITY: Attempt to reset password on an invalid account."); userSocket.SendLine("A new password was sent to your email address on file. Login with the new password to continue."); //userSocket.SendLine("No user account found please try again."); return; } }
/// <summary> /// React to the player speaking profanities. /// </summary> /// <param name="userSocket">The player's connection socket.</param> private static void HandleBadWords(IUserSocket userSocket) { // Do we send the player a message? if (sendMessageToPlayer) { userSocket.SendLine(playerMessage); } }
//gets the user to input thier email and checks it then sends the activation email private void EnterEmail() { int count = 1; bool Exit = false; //tell the user what we're doing and what to do userSocket.SendLine("Your account does not current have an email address associated with it."); userSocket.SendLine("Once you have entered your email address you will be disconnected, please reconnect when you have recived your confirmation email with your activation code."); while (!Exit) { userSocket.SendLine("Please enter you email address now:"); //wait for the email to be entered try { // if user disco, then socket is gone and we need to catch this exception s_TmpEmail = userSocket.GetResponse(); } catch { return; } //check if it really is an email if (Lib.Emailregex.IsMatch(s_TmpEmail)) { //if it is then store it this.s_Email = s_TmpEmail; //make a new activation code this.s_ActivationCode = this.CreateCode(); //make a new email this.MakeMailMessage(this.s_ActivationCode); //send the message if (this.SendEmail()) { Actor actor = Lib.GetByName(s_Username); if (actor != null) { actor["activationcode"] = s_ActivationCode; actor["email"] = s_Email; actor.Save(); userSocket.SendLine("Email valid ... we will now send you an email with your activation code and dissconnect you."); } //Lib.dbService.EmailUserActivation.UpdateActivationCode(s_Username, s_ActivationCode); //Lib.dbService.EmailUserActivation.UpdateUserEmailAddress(s_Username, s_Email); //userSocket.SendLine("Email valid ... we will now send you an email with your activation code and dissconnect you."); } Exit = true; } else { //if not then find out how many bad emails have been entered if (count == 3) { //if its 3 then wave goodbye userSocket.SendLine("Too many attepmts at entering an email address. Bye!"); Exit = true; } else { //if not just tell um they've been bad userSocket.SendLine("That email address is not valid."); } } count++; } }
public void Listen() { string username; string recv; bool fireCallback = true; active = true; try { Interlocked.Increment(ref Lib.connections); string clientip = userSocket.ClientEndpointId; Lib.log.Add(userSocket, null, "CONNECT (" + userSocket.ClientEndpointId + ") Online:" + Lib.connections); Commandprocessor cp = new Commandprocessor(); // Send the welcome screen to the user. userSocket.Send(Lib.Welcomescreen); userSocket.Send(Lib.Ansifboldyellow + "Developers: " + Lib.Ansifboldwhite + Lib.Creditsdev + "\r\n"); userSocket.Send(Lib.Ansifboldyellow + "Special Thanks: " + Lib.Ansifboldwhite + Lib.Creditsother + "\r\n\r\n" + Lib.Ansifwhite); // Authenticate this user. username = Lib.Authenticate(userSocket, cp); if (username == null) { // detected some socket error return; } if (username == null) { try { // If the user is already disconnected, this might fail so catch the exception userSocket.SendLine("Too many bad login attempts. Byte!"); Lib.Disco(userSocket, "too many bad logon attempts"); } catch { return; } return; } // Log this user as connected Actor theUser = Lib.GetByName(username); //theUser["connected"] = true; // Set the user's client socket theUser.UserSocket = this.userSocket; //theUser.Save(); while (enabled) { try { // if user disco, then socket is gone and we need to catch this exception recv = userSocket.GetResponse(); } catch { //Lib.PrintLine(DateTime.Now + " EXCEPTION in ClientListener (Waiting for client response): " + ex.Message + ex.StackTrace); // We should rather log these exceptions to the console // or to a log file return; } if (recv == null) { return; } cp.processcommand(userSocket, username, recv, false); } Lib.Disco(userSocket, "client listener switched off with the stoplistening method"); } catch (ThreadAbortException ex) { // Signal that we should just quit and not fire the // callback fireCallback = false; //Lib.PrintLine(DateTime.Now + " EXCEPTION in ClientListener (Thread aborted): " + ex.Message + ex.StackTrace); } finally { if (fireCallback) { // Fire the callback event IAsyncResult ar = clientDisconnectedEventHandler.BeginInvoke(this, null, null); } // We are no longer active active = false; } }