Setting external user as admin (Integration)

Last post 08-27-2009, 8:09 PM by cutechat. 9 replies.
Sort Posts: Previous Next
  •  08-19-2009, 3:24 AM 54776

    Setting external user as admin (Integration)

    Hi
     
    I'm trying out CuteChat for a project - and looks VERY good!
     
    However I have one major issue at the moment.
     
    I've written my own ChatProvider in order to integrate an existing user database, and it works very nicely.
     
    But I NEED to allow some of theese users to be admins - how?
     
    I would have thought that the code below would make every user an admin, but it doesn't?
     
    1. public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)  
    2.         {  
    3.             nickName = loginName;  
    4.             isAdmin = true;  
    5.             return true;  
    6.         }  
    7.   
     
  •  08-19-2009, 4:27 AM 54789 in reply to 54776

    Re: Setting external user as admin (Integration)

    HI woodbase,

    You can add a value in your user table, like role. if role==1 return true, else return false.
    1. public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)   
    2.     {   
    3.         nickName = loginName;   
    4.         isAdmin = IsAdminUser(loginName);   
    5.         return true;   
    6.     }   
    7.     public bool IsAdminUser(string loginName)   
    8.     {   
    9.         //check your user table use method GetUserRole()   
    10.         if (GetUserRole(loginName) == 1)   
    11.         {   
    12.             return true;   
    13.         }   
    14.         else  
    15.         {   
    16.             return false;   
    17.         }  
    Regards,
    Ken

     

  •  08-20-2009, 3:39 AM 54843 in reply to 54789

    Re: Setting external user as admin (Integration)

    Hi Ken
     
    Thx for Your answer - I'm afraid You misunderstood a little.
     
    In my code sample I was trying to make EVERYONE admin.
     
    But no one became an admin. That's where my problem is.
  •  08-25-2009, 2:45 AM 55001 in reply to 54843

    Re: Setting external user as admin (Integration)

    woodbase:
    Hi Ken
     
    Thx for Your answer - I'm afraid You misunderstood a little.
     
    In my code sample I was trying to make EVERY admin.
     
    But no one became an admin. That's where my problem is.
     
    I have located the problem - or one of them.
     
    The method GetUserInfo is never called?
  •  08-25-2009, 9:53 AM 55024 in reply to 55001

    Re: Setting external user as admin (Integration)

    Do you have any code like this :
     
    CuteChat.ChatProvider.Instance=new MyChatProvider();
    CuteChat.ChatSystem.Start(new CuteChat.AppSystem());
    Otherwise CuteChat will not know the MyChatProider class.
     
    Regards,
    Terry.
     
     
  •  08-26-2009, 1:35 AM 55051 in reply to 55024

    Re: Setting external user as admin (Integration)

    Hey Terry
     
    Yes it's located in the global.asax - under application_start.
     
    With VS2008 in debug mode I can see the it is my provider that's activated - however the GetUserInfo-method is never called?
  •  08-26-2009, 4:41 AM 55059 in reply to 55051

    Re: Setting external user as admin (Integration)

    Hi,
     
    How about the
     
    public override AppChatIdentity GetLogonIdentity()
     
    ??
     
    Does your code match the authentication method ?
     
    Regards,
    Terry
     
  •  08-27-2009, 2:29 AM 55091 in reply to 55059

    Re: Setting external user as admin (Integration)

    Yes it's called.
     
    1. public override AppChatIdentity GetLogonIdentity()  
    2. {  
    3.     if (!HttpContext.Current.Request.IsAuthenticated)  
    4.     {  
    5.         return null;  
    6.     }  
    7.     return new AppChatIdentity(HttpContext.Current.User.Identity.Name, false,  
    8.         HttpContext.Current.User.Identity.Name, HttpContext.Current.Request.UserHostAddress);  

  •  08-27-2009, 6:20 AM 55099 in reply to 55091

    Re: Setting external user as admin (Integration)

    I've found the error that I made.
     
    I was missing a method call:

    1.  return new AppChatIdentity(HttpContext.Current.User.Identity.Name, false,    
    2.          ToUserId(HttpContext.Current.User.Identity.Name), HttpContext.Current.Request.UserHostAddress); 
     Now it's working like a charm!
  •  08-27-2009, 8:09 PM 55126 in reply to 55099

    Re: Setting external user as admin (Integration)

    That is a good news.
     
    Glad to know you had fixed it.
     
    Regards,
    Terry
     
View as RSS news feed in XML