login nuovo
This commit is contained in:
parent
67677cbf42
commit
76b064389f
@ -24,7 +24,7 @@ namespace VirtualTask.Controllers
|
||||
ViewBag.Admin = admin;
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -20,7 +20,7 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
|
||||
client = new HttpClient();
|
||||
helper = new SessionHelper(this);
|
||||
// helper = new SessionHelper(this);
|
||||
_configuration = configuration;
|
||||
var key = _configuration["ApplicationInsights:rootUrlApi"];
|
||||
apiUrl = key;
|
||||
@ -32,40 +32,59 @@ namespace VirtualTask.Controllers
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Login(Login model)
|
||||
public IActionResult Login2(Login model)
|
||||
{
|
||||
string url = apiUrl + "loginTechnicalVT";
|
||||
Uri baseAddress = new Uri(url);
|
||||
client.BaseAddress = baseAddress;
|
||||
ViewBag.Error =string.Empty;
|
||||
ViewBag.Admin = string.Empty;
|
||||
|
||||
LoginOut loginOut = new LoginOut();
|
||||
string data = JsonConvert.SerializeObject(model);
|
||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
string risultato = response.Content.ReadAsStringAsync().Result;
|
||||
loginOut = JsonConvert.DeserializeObject<LoginOut>(risultato);
|
||||
helper = new SessionHelper(this);
|
||||
string url = apiUrl + "loginTechnicalVT";
|
||||
Uri baseAddress = new Uri(url);
|
||||
client.BaseAddress = baseAddress;
|
||||
ViewBag.Error = string.Empty;
|
||||
ViewBag.Admin = string.Empty;
|
||||
|
||||
LoginOut loginOut = new LoginOut();
|
||||
string data = JsonConvert.SerializeObject(model);
|
||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string risultato = response.Content.ReadAsStringAsync().Result;
|
||||
loginOut = JsonConvert.DeserializeObject<LoginOut>(risultato);
|
||||
|
||||
helper.SetStringValue("tok", loginOut.Tok);
|
||||
helper.SetStringValue("apiUrl", apiUrl);
|
||||
helper.SetStringValue("tenant", model.Tenant);
|
||||
helper.SetStringValue("tecnico", model.Username);
|
||||
helper.SetStringValue("admin", loginOut.Tcsuper != null ? loginOut.Tcsuper : "N");
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
loginOut = JsonConvert.DeserializeObject<LoginOut>(errMes);
|
||||
|
||||
helper.SetStringValue("errMsg", loginOut.err_detail);
|
||||
ViewBag.Error = loginOut.err_detail;
|
||||
return View();
|
||||
}
|
||||
|
||||
helper.SetStringValue("tok", loginOut.Tok);
|
||||
helper.SetStringValue("apiUrl", apiUrl);
|
||||
helper.SetStringValue("tenant", model.Tenant);
|
||||
helper.SetStringValue("tecnico", model.Username);
|
||||
helper.SetStringValue("admin", loginOut.Tcsuper != null ? loginOut.Tcsuper : "N");
|
||||
|
||||
return RedirectToAction("Index","Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
loginOut = JsonConvert.DeserializeObject<LoginOut>(errMes);
|
||||
foreach (var Elemento in ModelState.Values)
|
||||
{
|
||||
foreach (var Errore in Elemento.Errors)
|
||||
{
|
||||
string ErroreRilevato = Errore.ErrorMessage;
|
||||
}
|
||||
|
||||
helper.SetStringValue("errMsg", loginOut.err_detail);
|
||||
ViewBag.Error = loginOut.err_detail;
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IActionResult Login2()
|
||||
|
||||
@ -5,10 +5,12 @@ namespace VirtualTask.Models
|
||||
public class Login
|
||||
{
|
||||
[StringLength(20)]
|
||||
[Display(Name = "Username"), Required(ErrorMessage = "Username obbligatorio")]
|
||||
/// <summary>Username</summary>
|
||||
public string? Username { get; set; }
|
||||
|
||||
[StringLength(20)]
|
||||
[Display(Name = "Password"), Required(ErrorMessage = "Password obbligatoria")]
|
||||
/// <summary>Password</summary>
|
||||
public string? Password { get; set; }
|
||||
|
||||
|
||||
@ -6,8 +6,9 @@
|
||||
<div class="col-lg-8 col-md-12 col-sm-12 col-12">
|
||||
<div class="agy-contact-form">
|
||||
<h4 class="agy-sub-heading">Login</h4>
|
||||
<form asp-action="Login">
|
||||
<form asp-action="Login2">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" id="Tenant" value="VIRTU" name="Tenant" />
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12">
|
||||
<div class="agy-field-holder">
|
||||
@ -22,13 +23,13 @@
|
||||
<span asp-validation-for="Password" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
@* <div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12">
|
||||
<div class="agy-field-holder">
|
||||
<input asp-for="Tenant" class="agy-form-field" placeholder="Tenant" />
|
||||
<span asp-validation-for="Tenant" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-12">
|
||||
<input type="submit" value="Login" class="agy-btn submitForm" />
|
||||
<div class="response"></div>
|
||||
@ -36,4 +37,9 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4" style="color:red;">
|
||||
@ViewBag.Error
|
||||
</div>
|
||||
</div>
|
||||
@ -237,7 +237,7 @@ Purchase:
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-12">
|
||||
<div class="agy-banner-img text-center">
|
||||
@*<img src="~/assets/images/agency-banner-img.png" alt="agency" />*@
|
||||
<img src="~/assets/images/Bild1.png" alt="agency" />
|
||||
<img src="~/assets/images/Bild1.png" alt="Virtual Task" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
}
|
||||
},
|
||||
"ApplicationInsights": {
|
||||
"rootUrlApi": "https://api.poloinformatico.it:9000/api/Polo/",
|
||||
//"rootUrlApi": "https://api.poloinformatico.it:9000/api/Polo/",
|
||||
"rootUrlApi": "http://testapi.poloinformatico.it:9001/api/Polo/",
|
||||
"mittenteMail": "audiffredi@poloinformatico.it",
|
||||
"nomeMail": "Supporto Virtual Task",
|
||||
"pwdMail": "audicruz70",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user