Implementing IChatUserProvider

Submitted 6/1/2012 by Support

What is the IChatUserProvider used for?

The IChatUserProvider is used to handle user authorization, getting currently logged in user, getting user details and photos, ignoring other users and checking which users have administrator access.


What is the default implementation?

The software comes with two implementations:

  • eStreamChat.SampleProviders.ChatUserProvider - This is a sample implementation that logs users with random guest usernames and random gravatar images
  • eStreamChat.Classes.RemoteAuthUserProvider - This is implementation of the remote authorization SSO pattern. It takes the details of the currently logged user as parameters and uses secret key and sha1 hashing to prevent tampering. Instructions for enabling and using of the provider is available on the Automatic login with the Remote User Authentication Provider page.


Why would I need to implement it?

Each application has a different approach to user authentification and the Remote User Authentification Provider might not be suitable for all cases. By implementing the IChatUserProvider you could authorize users against Active Directory, any database, any remote service, etc.


What methods do I need to implement?

  • GetCurrentlyLoggedUser() - The method is called when the chat needs to know the currently logged in user
  • GetUser(string userId) - The method should return the user details for the specified user id
  • IgnoreUser(string userId, string ignoredUserId) - This method should store that the user specified in the first parameter has ignored the user specified in the second parameter
  • IsUserIgnored(string userId, string ignoredUserId) - This method should check if the user specified in the first parameter has previously ignored the user specified in the second one
  • IsChatAdmin(string userId, string chatRoomId) - The method should return if the user is administrator for the specified chat room
  • GetLoginUrl(string backURL) - If the user is not logged in and the GetCurrentlyLoggedUser() method returns null then the chat will redirect the user to log in. This method should return the url where the chat will send the user to log in. The backURL parameter specifies where the login page should redirect the user after the login.