예제 #1
0
        public static bool Authorize(string username, string password, out UserInfo userInfo)
        {
            var rval = false;

            userInfo = null;

            lock (m_mutex)
            {
                var internalClient = new InternalClient(Configuration, 0, username, password, false);
                try
                {
                    userInfo = internalClient.GetItem <UserInfo>("/userinfo", null);
                    if (userInfo != null)
                    {
                        rval = true;

                        var auth = new TrueDialogAuthElement
                        {
                            AccountId = userInfo.AccountId,
                            ApiKey    = userInfo.ApiKey.Key,
                            ApiSecret = userInfo.ApiKey.Secret,
                            UserName  = username,
                            Password  = password
                        };
                        m_client = new TrueDialogClient(new InternalClient(Configuration, auth));
                    }
                }
                catch (System.Exception)
                {
                    // just ignore
                }
            }

            return(rval);
        }