Adds support for SIREN exceptions to validation from the external provider
This commit is contained in:
parent
2d9851f642
commit
51bcdb73ee
1 changed files with 40 additions and 27 deletions
|
|
@ -262,7 +262,8 @@ namespace Yavsc.Controllers
|
||||||
if (credential == null)
|
if (credential == null)
|
||||||
return RedirectToAction("LinkLogin", new { provider = "Google" });
|
return RedirectToAction("LinkLogin", new { provider = "Google" });
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
ViewBag.Calendars = new GoogleApis.CalendarApi(_googleSettings.ApiKey)
|
ViewBag.Calendars = new GoogleApis.CalendarApi(_googleSettings.ApiKey)
|
||||||
.GetCalendars(credential);
|
.GetCalendars(credential);
|
||||||
}
|
}
|
||||||
|
|
@ -485,16 +486,28 @@ namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
var user = GetCurrentUserAsync().Result;
|
var user = GetCurrentUserAsync().Result;
|
||||||
var uid = user.Id;
|
var uid = user.Id;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
{
|
||||||
|
var exSiren = await _dbContext.ExceptionsSIREN.FirstOrDefaultAsync(
|
||||||
|
ex => ex.SIREN == model.SIREN
|
||||||
|
);
|
||||||
|
if (exSiren != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Exception SIREN:"+exSiren);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var taskCheck = await _cchecker.CheckAsync(model.SIREN);
|
var taskCheck = await _cchecker.CheckAsync(model.SIREN);
|
||||||
if (!taskCheck.success) {
|
if (!taskCheck.success)
|
||||||
|
{
|
||||||
ModelState.AddModelError(
|
ModelState.AddModelError(
|
||||||
"SIREN",
|
"SIREN",
|
||||||
_SR["Invalid company number"] + " (" + taskCheck.errorCode + ")"
|
_SR["Invalid company number"] + " (" + taskCheck.errorCode + ")"
|
||||||
);
|
);
|
||||||
_logger.LogWarning("Invalid company number, using key:"+_cinfoSettings.ApiKey);
|
_logger.LogInformation("Invalid company number, using key:" + _cinfoSettings.ApiKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue