Exemple #1
0
        public ForgotPasswordResponse ForgotPassword(string emailAddress)
        {
            try
            {
                User          user  = User.GetByEmail(emailAddress, Database);
                PasswordReset reset = user.PasswordResetsByUserId.AddNew();
                reset.Token            = Guid.NewGuid().ToString();
                reset.DateTime         = new Instant();
                reset.ExpiresInMinutes = PasswordResetTokensExpireInThisManyMinutes;
                reset.WasReset         = false;

                user.Save(Database);

                PasswordResetEmailData data = new PasswordResetEmailData
                {
                    Title            = "Password Reset",
                    UserName         = user.UserName,
                    ApplicationName  = ApplicationNameProvider.GetApplicationName(),
                    PasswordResetUrl = GetPasswordResetUrl(reset.Token)
                };
                string subject = "Password Reset for {0}"._Format(data.ApplicationName);
                string email   = user.Email;
                ComposePasswordResetEmail(subject, data).To(email).Send();
                FireEvent(ForgotPasswordSucceeded);
                return(GetSuccess <ForgotPasswordResponse>(reset.Token, "Password email was sent to {0}"._Format(email)));
            }
            catch (Exception ex)
            {
                LastException = ex;
                FireEvent(ForgotPasswordFailed);
                return(GetFailure <ForgotPasswordResponse>(ex));
            }
        }
 public ProcessRuntimeDescriptor LoadRuntimeDescriptor(ProcessRuntimeDescriptor likeThis)
 {
     return(LoadRuntimeDescriptor(
                likeThis.FilePath,
                likeThis.CommandLine,
                likeThis.MachineName,
                string.IsNullOrEmpty(likeThis.ApplicationName) ? ApplicationNameProvider.GetApplicationName(): likeThis.ApplicationName));
 }
Exemple #3
0
        /// <summary>
        /// Increments the file number if the current file number already exists.
        /// </summary>
        protected void SetNextFileInfo()
        {
            lock (fileLock)
            {
                string appName  = ApplicationNameProvider.GetApplicationName();
                string fileName = string.Format("{0}_{1}.{2}", appName, _fileNumber, FileExtension);

                _file = new FileInfo(Path.Combine(Folder.FullName, fileName));

                while (_file.Exists)
                {
                    _fileNumber += 1;
                    fileName     = string.Format("{0}_{1}.{2}", appName, _fileNumber, FileExtension);
                    _file        = new FileInfo(Path.Combine(Folder.FullName, fileName));
                }
            }
        }
Exemple #4
0
        public SendEmailResponse RequestConfirmationEmail(string emailAddress, int accountIndex = 0)
        {
            try
            {
                User user = User.GetByEmail(emailAddress, Database);
                if (user == null)
                {
                    throw new UserNameNotFoundException(emailAddress);
                }

                Account account = null;
                if (user.AccountsByUserId.Count == 0)
                {
                    account = Account.Create(user, ApplicationNameProvider.GetApplicationName(), user.UserName, false, Database);
                }
                else if (user.AccountsByUserId.Count <= accountIndex)
                {
                    account = user.AccountsByUserId[accountIndex];
                }
                else
                {
                    account = user.AccountsByUserId[0];
                }

                AccountConfirmationEmailData data = new AccountConfirmationEmailData
                {
                    Title           = "Account Confirmation",
                    UserName        = user.UserName,
                    ApplicationName = ApplicationNameProvider.GetApplicationName(),
                    ConfirmationUrl = GetConfirmationUrl(account.Token)
                };

                string subject = "Account Registration Confirmation";
                ComposeConfirmationEmail(subject, data).To(user.Email).Send();

                FireEvent(RequestConfirmationEmailSucceeded);
                return(GetSuccess <SendEmailResponse>(true));
            }
            catch (Exception ex)
            {
                LastException = ex;
                FireEvent(RequestConfirmationEmailFailed);
                return(GetFailure <SendEmailResponse>(ex));
            }
        }
Exemple #5
0
 public string GetApplicationName()
 {
     return(ApplicationNameProvider.GetApplicationName());
 }