コード例 #1
0
ファイル: NewAccount.ascx.cs プロジェクト: pkdevbox/Rock
        private void DisplaySuccess( Rock.Model.UserLogin user )
        {
            FormsAuthentication.SignOut();
            Rock.Security.Authorization.SetAuthCookie( tbUserName.Text, false, false );

            if ( user != null && user.PersonId.HasValue )
            {
                PersonService personService = new PersonService();
                Person person = personService.Get( user.PersonId.Value );

                if ( person != null )
                {
                    string url = LinkedPageUrl( "ConfirmationPage" );
                    if ( string.IsNullOrWhiteSpace( url ) )
                    {
                        url = ResolveRockUrl( "~/ConfirmAccount" );
                    }
                    var mergeObjects = new Dictionary<string, object>();
                    mergeObjects.Add( "ConfirmAccountUrl", RootPath + url.TrimStart( new char[] { '/' } ) );

                    var personDictionary = person.ToDictionary();
                    mergeObjects.Add( "Person", personDictionary );

                    mergeObjects.Add( "User", user.ToDictionary() );

                    var recipients = new Dictionary<string, Dictionary<string, object>>();
                    recipients.Add( person.Email, mergeObjects );

                    Email email = new Email( GetAttributeValue( "AccountCreatedTemplate" ) );
                    email.Send( recipients );

                    lSuccessCaption.Text = GetAttributeValue( "SuccessCaption" );
                    if ( lSuccessCaption.Text.Contains( "{0}" ) )
                        lSuccessCaption.Text = string.Format( lSuccessCaption.Text, person.FirstName );

                    ShowPanel( 5 );
                }
                else
                    ShowErrorMessage( "Invalid Person" );
            }
            else
                ShowErrorMessage( "Invalid User" );
        }