Michele: controllo token

This commit is contained in:
michele 2024-07-16 10:46:00 +02:00
parent 5702d2eb69
commit 5963d94057
4 changed files with 91 additions and 1 deletions

View File

@ -29,8 +29,14 @@ namespace SoftwayWeb.Controllers
public IActionResult Index(string id, string? codAutista, DateTime dataGiro, string? codMezzo, int? page = 1)
{
helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
string autista = string.Empty;
string dataGi = string.Empty;
string mezzo = string.Empty;
@ -103,6 +109,13 @@ namespace SoftwayWeb.Controllers
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "Giri/listaDestinazioneBySerial";
urlBase = urlBase + "?seriale=" + serial;

View File

@ -12,6 +12,7 @@ namespace SoftwayWeb.Controllers
string apiUrl = string.Empty;
string urlBase = string.Empty;
string errMes = string.Empty;
string token = string.Empty;
private readonly IConfiguration _configuration;
HttpClient client;
public GiriChiudiController(IConfiguration configuration)
@ -25,12 +26,28 @@ namespace SoftwayWeb.Controllers
// GET: GiriChiudiController
public ActionResult Index()
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
// return View();
return RedirectToAction("index", "giri");
}
public ActionResult Chiudi(string id, int nbanc,decimal imp)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
GiriConsegnaView model = new GiriConsegnaView();
List<GiriConsegnaView> lst=new List<GiriConsegnaView>();
@ -67,6 +84,14 @@ namespace SoftwayWeb.Controllers
{
//https://api.poloinformatico.it:8000/api/Giri/closeGiro?serialeGiro=0000000002&bancaliRecuperati=11&importoRecuperato=100
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "Giri/closeGiro?serialeGiro=";
urlBase = urlBase + model.SerialeGiro;

View File

@ -34,6 +34,12 @@ namespace SoftwayWeb.Controllers
{
helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
urlBase = apiUrl + "Giri/listaGiri?aperto="+ aperto;
//string url = apiUrl + "Giri/listaGiri";
//urlBase = url + "?token=" + token;
@ -104,6 +110,14 @@ namespace SoftwayWeb.Controllers
public IActionResult Create(bool sel)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
List<GiriConsegnaDaCreare> modelList = new List<GiriConsegnaDaCreare>();
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "Giri/listaGiriDaCreare";
@ -131,7 +145,15 @@ namespace SoftwayWeb.Controllers
public IActionResult PostIndex(IList<GiriConsegnaDaCreare> lst)
{
SessionHelper helper = new SessionHelper(this);
foreach(GiriConsegnaDaCreare g in lst)
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
foreach (GiriConsegnaDaCreare g in lst)
{
if(g.IsSelected==true)
{
@ -164,6 +186,13 @@ namespace SoftwayWeb.Controllers
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "Giri/listaGiri?aperto=" + aperto;
Uri baseAddress = new Uri(urlBase);
@ -194,6 +223,13 @@ namespace SoftwayWeb.Controllers
public IActionResult Bancali(GiriConsegnaView model)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "Giri/modGiro";

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NuGet.Common;
using SoftwayWeb.Models;
using System.Collections.Generic;
using System.Configuration;
@ -13,6 +14,7 @@ namespace SoftwayWeb.Controllers
string apiUrl = string.Empty;
string urlBase = string.Empty;
string errMes = string.Empty;
string token = string.Empty;
private readonly IConfiguration _configuration;
HttpClient client;
@ -32,6 +34,13 @@ namespace SoftwayWeb.Controllers
public IActionResult Elimina(string id)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
GiriConsegnaView model = new GiriConsegnaView();
List<GiriConsegnaView> modelList = new List<GiriConsegnaView>();
@ -66,6 +75,13 @@ namespace SoftwayWeb.Controllers
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login", "Login");
}
apiUrl = helper.GetStringValue("apiUrl");
urlBase = apiUrl + "Giri/delGiro?serialeGiro=";
urlBase = urlBase + model.SerialeGiro.TrimEnd();