Exemplo n.º 1
0
        public static Thread email_NewUser_Welcome(this TMUser tmUser)
        {
            var email     = tmUser.EMail;
            var userName  = tmUser.UserName;
            var serverUrl = SendEmails.TM_Server_URL;

            if (email.notValid())
            {
                "[SendNewUserEmails] can't sent email because email value is not set".error();
            }
            else if (userName.notValid())
            {
                "[SendNewUserEmails] can't sent email because userName value is not set".error();
            }
            else if (serverUrl.notValid())
            {
                "[SendNewUserEmails] can't sent email because server Url value is not set".error();
            }
            else
            {
                var subject     = TMConsts.EMAIL_SUBJECT_NEW_USER_WELCOME;
                var fullName    = tmUser.fullName();
                var userMessage = TMConsts.EMAIL_BODY_NEW_USER_WELCOME.format(fullName, tmUser.UserName, serverUrl);
                return(SendEmails.SendEmailToEmail(email, subject, userMessage));
            }
            return(null);
        }
Exemplo n.º 2
0
        public static bool SendPasswordReminderToUser(TMUser tmUser, Guid passwordResetToken)
        {
            UserGroup.Admin.assert();
            try
            {
                var secretData = TM_UserData.Current.SecretData;
                if (secretData.notNull())
                {
                    if (secretData.SmtpConfig != null)
                    {
                        TM_Server_URL = secretData.SmtpConfig.TM_Server_URL;
                    }
                }
                //mapTMServerUrl();
                var userMessage =
                    @"Hi {0}, a password reminder was requested for your account.

You can change the password of your {1} account using {3}/passwordReset/{1}/{2}

If you didn't make this request, please let us know at [email protected].
             ".format(tmUser.fullName(), tmUser.UserName, passwordResetToken, TM_Server_URL);

                SendEmailToEmail(tmUser.EMail, "TeamMentor Password Reset", userMessage);

                //userMessage = "(sent to: {0})\n\n{1}".format(tmUser.EMail, userMessage);
                //SendEmailToTM("(user email) TeamMentor Password Reset", userMessage);
                return(true);
            }
            catch (Exception ex)
            {
                ex.log();
            }
            UserGroup.None.assert();
            return(false);
        }
Exemplo n.º 3
0
        public static bool SendPasswordReminderToUser(TMUser tmUser, Guid passwordResetToken)
        {
            try
            {
                var userMessage =
                    @"Hi {0}, a password reminder was requested for your account.

You can change the password of your {1} account using {3}/passwordReset/{1}/{2}

If you didn't make this request, please let us know at [email protected].
             ".format(tmUser.fullName(), tmUser.UserName, passwordResetToken, TM_Server_URL);

                SendEmailToEmail(tmUser.EMail, "TeamMentor Password Reset", userMessage);

                //userMessage = "(sent to: {0})\n\n{1}".format(tmUser.EMail, userMessage);
                //SendEmailToTM("(user email) TeamMentor Password Reset", userMessage);
                return(true);
            }
            catch (Exception ex)
            {
                ex.log();
            }
            return(false);
        }
Exemplo n.º 4
0
        public void User_ExtMet_FullName()
        {
            var firstName           = "firstName".add_RandomLetters(5);
             var lastName            = "lastName".add_RandomLetters(5);
             var tmUser_NoValues     = new TMUser();
             var tmUser_JustFirst    = new TMUser() {FirstName = firstName};
             var tmUser_JustLast     = new TMUser() {LastName  = lastName};
             var tmUser_Both         = new TMUser() {FirstName = firstName, LastName  = lastName};

             //Check that values are correctly set
             Assert.IsTrue(tmUser_NoValues.notNull()  && tmUser_NoValues.FirstName.empty()   && tmUser_NoValues.LastName.empty(), "tmUser_NoValues setup");
             Assert.IsTrue(tmUser_JustFirst.notNull() && tmUser_JustFirst.FirstName.valid()  && tmUser_JustFirst.LastName.empty(), "tmUser_JustFirst setup");
             Assert.IsTrue(tmUser_JustLast.notNull()  && tmUser_JustLast.FirstName.empty()   && tmUser_JustLast.LastName.valid(), "tmUser_JustLast setup");
             Assert.IsTrue(tmUser_Both.notNull()      && tmUser_Both.FirstName.valid()       && tmUser_Both.LastName.valid(), "tmUser_Both setup");

             //Check that userName extension method is working ok
             var fullName_NoValues   = tmUser_NoValues.fullName();
             var fullName_JustFirst  = tmUser_JustFirst.fullName();
             var fullName_JustLast   = tmUser_JustLast.fullName();
             var fullName_Both       = tmUser_Both.fullName();

             Assert.AreEqual(fullName_NoValues , "");
             Assert.AreEqual(fullName_JustFirst, firstName);
             Assert.AreEqual(fullName_JustLast , "");
             Assert.AreEqual(fullName_Both     , "{0} {1}".format(firstName, lastName));

             //last check
             Assert.AreEqual("John Smith", new TMUser() { FirstName = "John", LastName = "Smith" }.fullName());
        }
Exemplo n.º 5
0
        public static bool SendPasswordReminderToUser(TMUser tmUser, Guid passwordResetToken)
        {
            UserGroup.Admin.assert();
            try
            {
                var secretData = TM_UserData.Current.SecretData;
                if (secretData.notNull())
                {
                    if (secretData.SmtpConfig != null)
                    {
                        TM_Server_URL = secretData.SmtpConfig.TM_Server_URL;
                    }
                }
                //mapTMServerUrl();
                var userMessage =
            @"Hi {0}, a password reminder was requested for your account.

            You can change the password of your {1} account using {3}/passwordReset/{1}/{2}

            If you didn't make this request, please let us know at [email protected].
             ".format(tmUser.fullName(), tmUser.UserName, passwordResetToken,TM_Server_URL);

                SendEmailToEmail(tmUser.EMail, "TeamMentor Password Reset", userMessage);

                //userMessage = "(sent to: {0})\n\n{1}".format(tmUser.EMail, userMessage);
                //SendEmailToTM("(user email) TeamMentor Password Reset", userMessage);
                return true;
            }
            catch (Exception ex)
            {
                ex.log();
            }
            UserGroup.None.assert();
            return false;
        }
Exemplo n.º 6
0
        public static bool SendPasswordReminderToUser(TMUser tmUser, Guid passwordResetToken)
        {
            try
            {
            var userMessage =
            @"Hi {0}, a password reminder was requested for your account.

            You can change the password of your {1} account using {3}/passwordReset/{1}/{2}

            If you didn't make this request, please let us know at [email protected].
             ".format(tmUser.fullName(), tmUser.UserName, passwordResetToken,TM_Server_URL);

                SendEmailToEmail(tmUser.EMail, "TeamMentor Password Reset", userMessage);

                //userMessage = "(sent to: {0})\n\n{1}".format(tmUser.EMail, userMessage);
                //SendEmailToTM("(user email) TeamMentor Password Reset", userMessage);
                return true;
            }
            catch (Exception ex)
            {
                ex.log();
            }
            return false;
        }