示例#1
0
        // Wrong Email or Password. Please try again. or click Forgot password to reset it.

        public LoginView()
        {
            InitializeComponent();
            DataContext = loginViewModel;
            loginViewModel.InvalidEmail += OnEmailValidation;
            ApiUtility.InitializeApiClient();
        }
 public LoginView()
 {
     InitializeComponent();
     loginViewModel = new LoginViewModel(this);
     DataContext    = loginViewModel;
     ApiUtility.InitializeApiClient();
 }
示例#3
0
 private static void CheckApiClient()
 {
     if (ApiUtility.ApiClient == null)
     {
         ApiUtility.InitializeApiClient();
     }
 }
        private async Task <bool> CheckOnlineLicenseAsync(TokenModel tokenModel)
        {
            tokenModel = CheckToken(tokenModel);

            if (ApiUtility.ApiClient == null)
            {
                ApiUtility.InitializeApiClient();
            }

            if (tokenModel.jwt == "")
            {
                return(false);
            }

            try
            {
                ApiUtility.ApiClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenModel.jwt);
                using (HttpResponseMessage result = await ApiUtility.ApiClient.GetAsync(WebApiUrl.licenseUrl))
                {
                    if (result.IsSuccessStatusCode)
                    {
                        return(await CheckAllLicensesAsync(result));
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
        /// <summary>
        /// Check if a user account is associeted to the given token
        /// </summary>
        /// <param name="token">The user license token</param>
        /// <returns>Pair of status code and HTTP resonse message. Status code is true if the user account is active.
        /// Otherwise status code is false</returns>
        protected async Task <KeyValuePair <bool, HttpResponseMessage> > CheckUserAccountAsync(string token)
        {
            ApiUtility.InitializeApiClient();

            ApiUtility.ApiClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            HttpResponseMessage userTokenHttpResponse = await ApiUtility.ApiClient.GetAsync(WebApiUrl.licenseUrl);

            return(new KeyValuePair <bool, HttpResponseMessage>(userTokenHttpResponse.IsSuccessStatusCode == true, userTokenHttpResponse));
        }
        public static async Task <bool> CheckInternetConnectionAsync()
        {
            ApiUtility.InitializeApiClient();

            try
            {
                using HttpResponseMessage result = await ApiUtility.ApiClient.GetAsync("https://www.google.com");

                return(result != null);
            }
            catch (Exception)
            {
                return(false);
            }
        }