Пример #1
0
 private UserInfo GetTokenInfo(AuthProtocol result)
 {
     if (result.Response.HasFlag(AuthProtocolResponseType.Error))
     {
         throw new Exception("Error in auth: " + result.ErrorCode + " ( " + result.ErrorStatus + " )");
     }
     if (result.Response.HasFlag(AuthProtocolResponseType.True))
     {
         return(new UserInfo {
             Ok = true, Expire = result.Expire, Login = result.Login, Token = result.Token
         });
     }
     return(new UserInfo());
 }
Пример #2
0
        /// <summary>
        /// </summary>
        /// <param name="login"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        public async Task <UserInfo> AuthAsync(string login, string pass)
        {
            AuthProtocol req = GetAuthReq(login, pass);

            return(GetTokenInfo(await ExecuteAsync(req)));
        }
Пример #3
0
 /// <summary>
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public AuthProtocol Execute(AuthProtocol request)
 {
     return(_client.Call(request));
 }
Пример #4
0
        /// <summary>
        /// </summary>
        /// <param name="login"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        public UserInfo Auth(string login, string pass)
        {
            AuthProtocol req = GetAuthReq(login, pass);

            return(GetTokenInfo(Execute(req)));
        }
Пример #5
0
 /// <summary>
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <AuthProtocol> ExecuteAsync(AuthProtocol request)
 {
     return(await _client.CallAsync(request));
 }