utente superadmin per le registrazioni
This commit is contained in:
parent
aab37a4240
commit
26aebcee21
@ -10,6 +10,7 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
string token = string.Empty;
|
||||
string admin = string.Empty;
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
@ -19,6 +20,8 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
admin = helper.GetStringValue("admin");
|
||||
ViewBag.Admin = admin;
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
|
||||
@ -18,8 +18,7 @@ namespace VirtualTask.Controllers
|
||||
|
||||
public LoginController(IConfiguration configuration)
|
||||
{
|
||||
//apiUrl = "http://10.0.0.187:8000/api/Polo/";
|
||||
//apiUrl = "http://testapi.poloinformatico.it:9001/api/Polo/";
|
||||
|
||||
client = new HttpClient();
|
||||
helper = new SessionHelper(this);
|
||||
_configuration = configuration;
|
||||
@ -30,10 +29,6 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
//public IActionResult Login()
|
||||
//{
|
||||
// return View();
|
||||
//}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
@ -43,6 +38,7 @@ namespace VirtualTask.Controllers
|
||||
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);
|
||||
@ -57,6 +53,8 @@ namespace VirtualTask.Controllers
|
||||
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
|
||||
@ -70,44 +68,9 @@ namespace VirtualTask.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IActionResult Login2()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
//[HttpPost]
|
||||
//public IActionResult Login2(Login model)
|
||||
//{
|
||||
// string url = apiUrl + "loginTechnicalVT";
|
||||
// Uri baseAddress = new Uri(url);
|
||||
// client.BaseAddress = baseAddress;
|
||||
// ViewBag.Error = 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);
|
||||
// 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();
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,16 +15,20 @@ namespace VirtualTask.Controllers
|
||||
string token = string.Empty;
|
||||
string tenant = string.Empty;
|
||||
string errMes = string.Empty;
|
||||
string admin = string.Empty;
|
||||
|
||||
|
||||
HttpClient client;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public RegistrazioniController(IConfiguration configuration)
|
||||
{
|
||||
|
||||
client = new HttpClient();
|
||||
_configuration = configuration;
|
||||
var key = _configuration["ApplicationInsights:rootUrlApi"];
|
||||
apiUrl = key;
|
||||
|
||||
}
|
||||
|
||||
#region INDEX
|
||||
@ -33,6 +37,8 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
urlBase = apiUrl + "RegistrazioniList";
|
||||
admin = helper.GetStringValue("admin");
|
||||
ViewBag.Admin = admin;
|
||||
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
|
||||
@ -193,7 +193,10 @@ namespace VirtualTask.Models
|
||||
/// <summary>Status</summary>
|
||||
public string? err_status_code { get; set; }
|
||||
|
||||
/// <summary>flag admin</summary>
|
||||
public string? Tcsuper { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
@{
|
||||
string admin = ViewBag.Admin;
|
||||
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
@ -144,7 +146,12 @@ Purchase:
|
||||
<li><a asp-area="" asp-controller="Chiamate" asp-action="Index">Chiamate</a></li>
|
||||
<li><a asp-area="" asp-controller="Progressivi" asp-action="Index">Progressivi</a></li>
|
||||
<li><a asp-area="" asp-controller="AziendaRif" asp-action="Index">Dati Azienda</a></li>
|
||||
<li><a asp-area="" asp-controller="Registrazioni" asp-action="Index">Richieste</a></li>
|
||||
@{
|
||||
if(admin.Equals("S"))
|
||||
{
|
||||
<li><a asp-area="" asp-controller="Registrazioni" asp-action="Index">Richieste</a></li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user