Example #1
0
        public bool ResetAuthToken()
        {
            try
            {
                SecureStorage.Remove(_tokenNameKey);
                SecureStorage.Remove(_userIdKey);
                SecureStorage.Remove(_tokenUsernameKey);
                SecureStorage.Remove(_tokenEmailKey);
                SecureStorage.Remove(_tokenImgUrlKey);
                SecureStorage.Remove(_tokenRoleKey);
            }
            catch (Exception e)
            {
                HandleError.Process("TokenStoreService", "ResetAuthTokenAsync", e, false);
                ParameterManager par = new ParameterManager();
                par.Delete(_tokenNameKey);
                par.Delete(_userIdKey);
                par.Delete(_tokenUsernameKey);
                par.Delete(_tokenEmailKey);
                par.Delete(_tokenImgUrlKey);
                par.Delete(_tokenRoleKey);
            }

            return(true);
        }
Example #2
0
 public void NewFile()
 {
     try
     {
         File.WriteAllText(_pathToLog, $"{DateTime.Now.ToString()} started", Encoding.UTF8);
     }
     catch (Exception e)
     {
         HandleError.Process("Logger", "NewFile", e, false);
     }
 }
Example #3
0
 public void SaveReport()
 {
     try
     {
         File.AppendAllText(_pathToLog, _sb.ToString(), Encoding.UTF8);
         _sb = new StringBuilder();
     }
     catch (Exception e)
     {
         HandleError.Process("Logger", "SaveReport", e, false);
     }
 }
Example #4
0
        private async Task <string> getDataByKey(string keyName)
        {
            string datavalue = string.Empty;

            try
            {
                datavalue = await SecureStorage.GetAsync(keyName);
            }
            catch (Exception e)
            {
                HandleError.Process("TokenStoreService", "GetAuthTokenAsync", e, false);
            }

            //если значение не было сохранено в безопасное хранилище, ищем его в небезопасном - Android 4.4.2
            if (string.IsNullOrEmpty(datavalue))
            {
                ParameterManager par = new ParameterManager();
                par.Get(keyName, out datavalue);
            }

            return(datavalue);
        }
Example #5
0
        public async Task <bool> SetAuthDataAsync(string authToken, string userId, string username, string email, string imgUrl = "", string role = "")
        {
            try
            {
                SecureStorage.Remove(_tokenNameKey);
                await SecureStorage.SetAsync(_tokenNameKey, authToken);

                SecureStorage.Remove(_userIdKey);
                await SecureStorage.SetAsync(_userIdKey, userId);

                SecureStorage.Remove(_tokenUsernameKey);
                await SecureStorage.SetAsync(_tokenUsernameKey, username);

                SecureStorage.Remove(_tokenEmailKey);
                await SecureStorage.SetAsync(_tokenEmailKey, email);

                SecureStorage.Remove(_tokenImgUrlKey);
                await SecureStorage.SetAsync(_tokenImgUrlKey, imgUrl);

                SecureStorage.Remove(_tokenRoleKey);
                await SecureStorage.SetAsync(_tokenRoleKey, role);
            }
            catch (Exception e)
            {
                HandleError.Process("TokenStoreService", "SetAuthDataAsync", e, false);
                ParameterManager par = new ParameterManager();
                par.Set(_tokenNameKey, authToken);
                par.Set(_userIdKey, userId);
                par.Set(_tokenUsernameKey, username);
                par.Set(_tokenEmailKey, email);
                par.Set(_tokenImgUrlKey, imgUrl);
                par.Set(_tokenRoleKey, role);
            }

            return(true);
        }