Ejemplo n.º 1
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);
        }