using System.Collections.Specialized;
using User;

namespace YGNT.Infrastructure.Grpc
{
    /// <summary>
    /// 用户验证
    /// </summary>
    public class GrpcUserAtuh
    {
        /// <summary>
        /// 验证token
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public static NameValueCollection AtuhToken(string token)
        {
            var client = new User_Atuh.User_AtuhClient(GrpcHost.userChannel);
            var reply = client.UserAtuhToken(new UserAtuhTokenParameter() { Token = token });

            NameValueCollection nameValueCollection = new NameValueCollection();
            nameValueCollection.Add("UserID", reply.UserId);
            foreach (var item in reply.Extension)
            {
                nameValueCollection.Add(item.Key.ToLower(), item.Value);
            }
            return nameValueCollection;
        }
    }
}
