Esempio n. 1
0
        public static void Handle( SocketClient client,RegisterRequest request)
        {
            var registerInfo = request.RegisterInformation;
            var user = new Accounts
            {
                Username = registerInfo[0],
                Password = GetStringSha1Hash(registerInfo[1]),
                Email = registerInfo[2],
                Registerip = client.Handler.RemoteEndPoint.ToString(),
                Lastloginip = client.Handler.RemoteEndPoint.ToString(),
                Registertime = DateTime.Now,
                Lastlogintime = DateTime.Now,
                Locked = false,
                Verified = false,
                Verificationcode = Guid.NewGuid().ToString()
            };

            var reply = new LoginResponse();
            try
            {
                if (AccountRepository.GetAccount(user.Username, null) == null)
                {
                    if (AccountRepository.GetAccount(null, user.Email) == null)
                    {
                        BaseRepository.Add(user);
                        reply.ResponseType = LoginResponseType.AccountCreated;
                        reply.AccountId = user.Accountid;
                        EmailSender.SendWelcomeEmail(user);
                    }
                    else
                        reply.ResponseType = LoginResponseType.EmailInUse;
                }
                else
                    reply.ResponseType = LoginResponseType.UsernameInUse;
            }
            catch (Exception e)
            {
                reply.ResponseType = LoginResponseType.DatabaseError;
                Logger.Error(e.Message);
            }
            client.Send(reply);
        }
Esempio n. 2
0
 public static void SendWelcomeEmail(Accounts account)
 {
     SmtpClient client = new SmtpClient("mail.michaelandrepont.com")
     {
         Timeout = 10000,
         DeliveryMethod = SmtpDeliveryMethod.Network,
         UseDefaultCredentials = false,
         Credentials = new NetworkCredential("*****@*****.**", "dn9u(T]C@G49")
     };
     // That password is not used for anything by the way.
     var message =
         new MailMessage(new MailAddress("*****@*****.**", "Michael's TicTacToe Program"),
             new MailAddress(account.Email))
         {
             Subject = "Please Verify Your Account",
             Body = "Please use " + account.Verificationcode +
                    " in the password box the next time you login to this account to verify your account."
         };
     client.Send(message);
 }
Esempio n. 3
0
 public static void SendRestEmail(Accounts account)
 {
     SmtpClient client = new SmtpClient("mail.michaelandrepont.com")
     {
         Timeout = 10000,
         DeliveryMethod = SmtpDeliveryMethod.Network,
         UseDefaultCredentials = false,
         Credentials = new NetworkCredential("*****@*****.**", "dn9u(T]C@G49")
     };
     // That password is not used for anything by the way.
     var message =
         new MailMessage(new MailAddress("*****@*****.**", "Michael's TicTacToe Program"),
             new MailAddress(account.Email))
         {
             Subject = "Forgot Your Password?",
             Body = "Everybody forgets their password from time to time... it is okay we wont judge ;)" +
                    " \n To reset your password to a new password please login with your account username and the" +
                    " verification code followed by the new password like this below" +
                    $" \n {account.Verificationcode}:Password \n and then your password will be changed."
         };
     client.Send(message);
 }