Always Use Display Name - Never UserName

Last post 11-08-2011, 7:48 AM by markstevenpringle. 1 replies.
Sort Posts: Previous Next
  •  11-07-2011, 2:45 PM 71201

    Always Use Display Name - Never UserName

    I'm testing Cute Chat to see if I want to buy it for my websites. I've incorporated Cute Chat into an asp.net membership website. However, I NEVER want the users to see the Username since this is used for login to the website. Is there a way to always prompt for a Display Name when entering a chat room and ALWAYS use THAT in the chat rooms - NEVER the username? It's OK to use the username in the database.
     
    Here is the global.asax code I'm currently using.
     
    1. <%@ Application Language="C#" %>  
    2. <%@ Import Namespace="CuteChat" %>  
    3.   
    4. <script runat="server">  
    5.   
    6.     void Application_Start(object sender, EventArgs e) {  
    7.         if (!Roles.RoleExists("Administrator")) Roles.CreateRole("Administrator");  
    8.   
    9.         ChatProvider.Instance = new AspNetChatProvider();  
    10.         ChatSystem.Start(new AppSystem());  
    11.           
    12.     }  
    13.   
    14.     static private string CuteChatConnectionStringConfigName = "SQL2008_355184_poetrysoupConnectionString";  
    15.       
    16.     public string GetConnectionString(string reserved)  
    17.     {  
    18.         return System.Configuration.ConfigurationManager.ConnectionStrings[CuteChatConnectionStringConfigName].ConnectionString;  
    19.     }  
    20.   
    21.   
    22.     public class AspNetChatProvider : ChatProvider  
    23.     {  
    24.         public override string GetConnectionString()  
    25.         {  
    26.             return System.Configuration.ConfigurationManager.ConnectionStrings[CuteChatConnectionStringConfigName].ConnectionString;  
    27.         }  
    28.   
    29.         public override AppChatIdentity GetLogonIdentity()  
    30.         {  
    31.             System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser();  
    32.   
    33.             if (user != null && user.IsApproved)  
    34.             {  
    35.                 return new AppChatIdentity(user.UserName, false, ToUserId(user.UserName), HttpContext.Current.Request.UserHostAddress);  
    36.             }  
    37.   
    38.             return null;  
    39.         }  
    40.           
    41.         public override string  FindUserLoginName(string nickName)  
    42.         {  
    43.             System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(nickName,false);  
    44.             if (user != null && user.IsApproved)  
    45.                 return user.UserName;  
    46.             return null;  
    47.         }  
    48.         public override bool  GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)  
    49.         {  
    50.             System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(loginName, false);  
    51.             if (user != null && user.IsApproved)  
    52.             {  
    53.                 nickName=user.UserName;  
    54.                 isAdmin=Roles.IsUserInRole(user.UserName,"Administrator");  
    55.                 return true;  
    56.             }  
    57.             return false;  
    58.         }  
    59.   
    60.         public override bool ValidateUser(string username, string password)  
    61.         {  
    62.             if (!System.Web.Security.Membership.ValidateUser(username, password))  
    63.             {  
    64.                 return false;  
    65.             }  
    66.   
    67.             System.Web.Security.FormsAuthentication.SetAuthCookie(username, false, HttpRuntime.AppDomainAppVirtualPath);  
    68.   
    69.             return true;  
    70.         }  
    71.     }  
    72.   
    73.       
    74. </script> 

     
  •  11-08-2011, 7:48 AM 71224 in reply to 71201

    Re: Always Use Display Name - Never UserName

    Well, I just created a Display Name that was a combination of a users first name, last name, and id. This created a unique but identifiable Display Name that replaced the UserName. This solved my problem.
View as RSS news feed in XML