Error for Xamarin IOS Firebase AuthDataResult does not Contain ProfileChangeRequest() - c#

I'm getting an error saying AuthDataResult does not contain ProfileChangeRequest() when i try to change the name of the user. I've to research online and read the firebase docs as well but no luck.
public static async Task Register(UIViewController thisView,
string inpName,
string inpEmail,
string inpPassword)
{
bool done = false;
AppDataClass.auth.CreateUser(inpEmail, inpPassword, (user, error) =>
{
if (error != null)
{
AlertShow.Alert(thisView, "Error",
"This went wrong: " + error.UserInfo.Description);
return;
}
UserProfileChangeRequest changeReq = user.ProfileChangeRequest;
changeReq.DisplayName = inpName;
changeReq.CommitChanges((profileError) =>
{
if (profileError != null)
{
AlertShow.Alert(thisView, "Error",
"Profile Error: " + profileError);
return;
}
done = true;
});
});
while (!done)
{
await Task.Delay(50);
}
}

If you read the document about method -signInWithEmail:password:completion:, the call back it retures is a FIRAuthDataResultCallback , the first parameter here is FIRAuthDataResult.
So the user should be:
user.user.ProfileChangeRequest
To make it clear:
public static async Task Register(UIViewController thisView,
string inpName,
string inpEmail,
string inpPassword)
{
bool done = false;
AppDataClass.auth.CreateUser(inpEmail, inpPassword, (authDataResult, error) =>
{
if (error != null)
{
AlertShow.Alert(thisView, "Error",
"This went wrong: " + error.UserInfo.Description);
return;
}
UserProfileChangeRequest changeReq = authDataResult.user.ProfileChangeRequest;
changeReq.DisplayName = inpName;
});
while (!done)
{
await Task.Delay(50);
}
}
Refer: ERROR is value of type 'AuthDataResult' has no member 'uid'

Related

How can I make an auto injection detector in c#?

I want to make an auto injection scanner in any given website and I have to use c#.
I tried some things that I found online and none of them worked for me, until i find selenium but i keep getting this error message: "OpenQA.Selenium.ElementNotInteractableException: 'element not interactable", and I have no idea why.
I didn't find anything helpful online and I think the problem may be with selenium.
I tried to find SQL, JS and BASH injections, but the script fails when i try to interact with an input. I am using OWASP juice shop to test my code.
This is my code:
static int _crntTypeOfInjection;
const int ESQL = 0, EJS = 1, EBASH = 2;
static public bool IsImportantInput(string type)
{
bool valid = false;
string[] importantTypes = new string[] { "text", "email", "password", "search", "url" };
foreach (string check in importantTypes)
{
if (type == check)
{
return true;
}
}
return false;
}
public static string getCrntInjection()
{
switch (_crntTypeOfInjection)
{
case ESQL:
return "\' OR 1=1;--";
break;
case EBASH:
return "; echo Test";
break;
case EJS:
return "<img src=\"http:\\\\url.to.file.which\\not.exist\" onerror=alert(\"JS injection success\");>";
break;
}
return "defult";
}
static public bool AttackSuccessful(string normalPage, string InjectedPage, string MainUrl, string afterClickUrl)
{
if (afterClickUrl != MainUrl || InjectedPage.Contains("Internal Server Error") || InjectedPage.Contains("JS injection success") || InjectedPage.Contains("Test"))
{
return true;
}
return false;
}
static public void Injection(string url)
{
string InjectedPage = "", NormalPage = "", AfterClickUrl = "";
var driver = new ChromeDriver("C:\\Users\\nirya\\");
driver.Url = url;
Console.WriteLine(driver.PageSource);
Actions a = new Actions(driver);
foreach (var button in driver.FindElements(By.CssSelector("button")))
{
// INJECTED PAGE
a.MoveByOffset(0, 0).Click().Perform();
foreach (IWebElement input in driver.FindElements(By.TagName("input")))
{
Console.WriteLine(input.Text);
Console.WriteLine(input.TagName);
try
{
if (IsImportantInput(input.GetAttribute("type")))
{
input.Click(); // *** HERE IS THE PROBLEM ***
input.Clear();
input.SendKeys(getCrntInjection());
}
}
catch (NoSuchElementException)
{
continue;
}
}
button.Click();
InjectedPage = driver.PageSource;
AfterClickUrl = driver.Url;
driver.Navigate().Back();
// NORMAL PAGE
a.MoveByOffset(0, 0).Click().Perform();
foreach (IWebElement input in driver.FindElements(By.CssSelector("input")))
{
try
{
if (IsImportantInput(input.GetAttribute("type")))
{
input.Clear();
input.SendKeys("normal");
}
}
catch (NoSuchElementException)
{
continue;
}
}
button.Click();
NormalPage = driver.PageSource;
driver.Navigate().Back();
if (AttackSuccessful(NormalPage, InjectedPage, url, AfterClickUrl))
{
// add to database
}
}
}
static void Main(string[] args)
{
Injection("http://localhost:3000/#/login");
}
Is there a problem with my code? Or is there another library that i can use instead?

DELETE request works from insomnia/postman but not from the frontend

DELETE request give 204 response code from Insomnia/Postman, But from the frontend it gives error for Delete request.
Please find my Service code below :
public bool Dissociate(string envCode, string serialNumber, string gatewayType)
{
envCode.ThrowIfNull();
serialNumber.ThrowIfNull();
gatewayType.ThrowIfNull();
if (!IsAssociated(envCode, serialNumber, gatewayType))
{
_logService.Warn($"DspService - Dissociate - {gatewayType} {serialNumber} not associated to DSP tenant on environment {envCode}");
return false;
}
EnvironmentSettings dspEnvSettings = GetEnvironmentSettings(envCode);
string baseUri = DspHelper.GetBaseUriByAction(dspEnvSettings, DspActionType.Dissociate);
string dspDeviceId = DspHelper.BuildDeviceId(serialNumber, gatewayType, true);
string uri = $"{baseUri}/registry/devices/{dspDeviceId}/claim";
var body = new
{
Claimable = true
};
try
{
var authToken = GetAuthorizationHeader(dspEnvSettings, DspActionType.Dissociate);
RunDspCommand<bool>(dspEnvSettings, uri, authToken, body, HttpMethod.Put, DspActionType.Dissociate);
return true;
}
catch (Exception e)
{
_logService.ErrorException(e, $"DspService - Dissociate - Error dissociating {gatewayType} {serialNumber} on environment {envCode}. {uri}");
throw;
}
}
Please find my insomnia response:
CONTROLLER :
[AcceptVerbs("DELETE")]
[Route("dissociate")]
public bool Dissociate([FromUri] string gatewayType, [FromUri] string gatewaySerial)
{
if (string.IsNullOrEmpty(gatewaySerial) || string.IsNullOrEmpty(gatewayType))
{
this.BadRequestResponse();
}
var connectedUser = this.permissionService.GetConnectedUser();
this.permissionService.CheckRolePermission(connectedUser.Role, PermissionConstant.DissociateComX);
bool hasSucceeded = this.dspService.Dissociate(connectedUser.CurrentEnvironment, gatewaySerial, gatewayType);
if (hasSucceeded)
{
this.applicationDataAccess.LogAction(connectedUser.CurrentEnvironment, connectedUser.Email, LogActionConstants.Action.DissociateComX, string.Format(LogActionConstants.Message.DissociateComX, gatewayType, gatewaySerial));
}
else
{
this.BadRequestResponse("cannot deprovioned comx");
}
return hasSucceeded;
}
It gives the exception in the Service Code
RunDspCommand<bool>(dspEnvSettings, uri, authToken, body, HttpMethod.Put, DspActionType.Dissociate);
Below is my front end code.
controller.ts
dissociateGateway() {
if (!this.isDspGateway || this.isLoadingDspState || this.isDissociating
|| this.gateway.FirmwareUpgradeWorkflow || this.gateway.DeleteGatewayWorkflow
|| !this.isAssociated()) {
return;
}
this.modalService.confirm(
`The ${this.gateway.Type} ${this.gateway.SerialNumber} will be dissociated from its DSP tenant ${this
.dspGatewayState.Tenant}.`,
'Are you sure you want to dissociate the gateway from DSP tenant?')
.then(() => {
this.isDissociating = true;
this.dspService.dissociate(this.gateway.Type, this.getDeviceId())
.then(() => this.getDspGatewayState())
.catch((e) => {
if (e) {
this.modalService.error('Error dissociating the gateway. Please retry later');
}
})
.finally(() => this.isDissociating = false);
});
}
service.ts
dissociate(gatewayType: string, gatewaySerial: string): ng.IPromise<boolean> {
var uri = this.ROUTES.dissociate
.replace('{:gatewayType}', gatewayType.toString())
.replace('{:gatewaySerial}', gatewaySerial);
return this.restService
.delete(uri, null)
.then((response: any) => {
return response;
})
.catch((response: any) => {
return this.$q.reject(response);
});
}
Path :
dissociate: '/dsp/dissociate?gatewaytype={:gatewayType}&gatewaySerial={:gatewaySerial}',
If you need more information please comment below.
Please help me. Thanks in Advance.

How to fix 'Reference to type 'IAsyncEnumerable<>' claims it is defined in 'System.Interactive.Async', but it could not be found'?

Until yesterday it was working and I didn't even touch the code but this error popped up and since that it just says this:
Reference to type 'IAsyncEnumerable<>' claims it is defined in
'System.Interactive.Async', but it could not be found.
I did a discord bot and I want to delete messages with it
[Command("clear")]
public async Task Clear(string StringNum = null)
{
try
{
if (!Context.Guild.CurrentUser.GuildPermissions.ManageMessages)
{
await ReplyAsync("Sorry, I don't have permission for this!");
}
else
{
var user = Context.User as SocketGuildUser;
if (user.GuildPermissions.ManageMessages)
{
int IntNum = 1;
bool intparse = int.TryParse(StringNum, out int n);
if (intparse)
{
IntNum = int.Parse(StringNum);
}
var messages = await Context.Channel.GetMessagesAsync(IntNum + 1).Flatten();
await (Context.Channel as SocketTextChannel).DeleteMessagesAsync(messages);
}
else
{
await ReplyAsync("You don't have permission for this command!");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.GetBaseException());
}
}
The error is at the line where I try to get the messages
I ran in to this. I had to install System.Interactive.Async 3.1.1 rather than 4.0.0. So I assume it is no longer in 4.0.0.

Kendo Grid duplication message

I am using Kendo grid and I have stopped the grid from saving duplicate values as follows in create method:
var results = new List<ProviderTypeMasterViewModel>();
try
{
_logger.LogInformation("ProviderTypeMastersController ProviderType_Create Start");
foreach (var ProviderTypeMaster in ProviderTypeMasterList)
{
TblProviderTypeMaster ptm = new ProviderTypeMasterViewModel().ToModel(ProviderTypeMaster);
var provd = _context.TblProviderTypeMasters.Where(p => p.ProviderTypeName == ProviderTypeMaster.ProviderTypeName).ToList();
if (provd != null && provd.Count() == 0)
{
if (ProviderTypeMasterList != null && ModelState.IsValid)
{
string userID = GetUserID();
providerTypeMasterService.SaveProviderTypeMaster(ProviderTypeMaster, userID);
}
}
else
{
duplicate = true;
//Session["ErrMsg"] = "Already Exists";
//return RedirectToAction("ProviderType_Read", "ProviderTypeMasters");
}
}
_logger.LogInformation("ProviderTypeMastersController ProviderType_Create Complete");
}
catch (Exception e)
{
_logger.LogError("ProviderTypeMastersController ProviderType_Create Failed - " + e.Message);
}
return Json(results.ToDataSourceResult(request, ModelState));
And in the read method I have displayed the error message to the user as follows
try
{
if (duplicate == true)
{
TempData["ErroMsg"] = "Already Exists";
}
_logger.LogInformation("In ProviderTypeMastersController ProviderType_Read");
return Json(providerTypeMasterService.ListProviderTypeMaster().ToDataSourceResult(request));
}
catch (Exception e)
{
_logger.LogError("ProviderTypeMastersController ProviderType_Read Failed - " + e.Message);
}
return View();
The duplication process has stopped. But I am unable to show the error message to the user. Can anyone let me know what I should do where I have gone wrong. I have tried using ViewBag,ViewData,TempData.
This is my View
<div>
if (TempData["ErroMsg"] != null)
{
<p>#TempData["ErroMsg"].ToString()</p>
}
you can use DataBinding() and DataBound() function of kendo grid...these functions call in client side after Read method on server side..for example you can set a field and decision with this field

await on long service call behaves differently in Microsoft Bot Framework

I have two dialogs called from root dialog based on the prompt response.
Both dialogs internally prepare request and call a service class. Weird thing is one dialog resumes with response from service but the other though receives response from service is not resuming.
Below method works fine and resumes the call at if (searchResult != null && searchResult.Item1 != null)
public virtual async Task MessageRecievedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
{
var message = await result;
if (message.Text == "quit")
{
context.Done<object>(null);
}
else
{
try
{
var srm = new CoveoRestSearchService.CoveoSearchRequestModel
{
Query = message.Text,
EnableDidYouMean = true,
QuerySource = CoveoRestSearchService.Constants.SWEATERSSOURCE
};
var searchResult = await csp.PerformSearch(srm);
if (searchResult != null && searchResult.Item1 != null)
{
await CardUtil.showHeroCard(message, searchResult.Item1);
}
else
{
await context.PostAsync($"No search results for {message.Text} found");
}
await PostSearchUsageAnalyticsToCoveo(context, srm, searchResult.Item2);
}
catch (Exception e)
{
Debug.WriteLine($"Error when searching : {e.Message}");
}
finally {
context.Wait(MessageRecievedAsync);
}
}
}
This below one though looks identical is not resuming the if (response != null)
public virtual async Task MessageRecievedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
{
var message = await result;
if (message.Text == "quit")
{
context.Done<object>(null);
}
else
{
try
{
var currentDate = DateTime.UtcNow;
string toDate = currentDate.ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
string fromDate = currentDate.AddDays(-7).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
MetricsQuery = MetricsQuery.Replace("{fromISODate}", fromDate);
MetricsQuery = MetricsQuery.Replace("{toISODate}", toDate);
MetricsQuery = MetricsQuery.Replace("{term}", message.Text);
var response = await cuawc.MetricSearchUsageToCoveoAsync(MetricsQuery
.Replace(" ", "%20")
.Replace("!=", "!%3D")
.Replace("==", "%3D%3D")
.Replace(":", "%3A"));
if (response != null)
{
var message_from_bot = context.MakeMessage();
}
//message_from_bot.Attachments = new List<Attachments>();
await context.PostAsync("Please enter the search term for metrics");
}
catch (Exception e)
{
Debug.WriteLine($"Error when pulling metrics : {e.Message}");
}
finally
{
context.Wait(MessageRecievedAsync);
}
}
}
Struggling from past 2 days to figure what is wrong!!

Categories

Resources