Login
This commit is contained in:
parent
968de1e6fe
commit
982c68ed31
@ -15,6 +15,15 @@ namespace VirtualTask.Controllers
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
string t = HttpContext.Session.GetString("tok");
|
||||
if (!string.IsNullOrEmpty(t))
|
||||
{
|
||||
ViewBag.Token = t;
|
||||
|
||||
}
|
||||
else
|
||||
ViewBag.Token = string.Empty;
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
50
Controllers/LoginController.cs
Normal file
50
Controllers/LoginController.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using VirtualTask.Models;
|
||||
|
||||
namespace VirtualTask.Controllers
|
||||
{
|
||||
public class LoginController : Controller
|
||||
{
|
||||
|
||||
//https://localhost:7068/api/Polo/loginTechnical
|
||||
Uri baseAddress = new Uri("http://10.0.0.187:5068/api/Polo/loginTechnical");
|
||||
HttpClient client;
|
||||
public LoginController()
|
||||
{
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
}
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult Login()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Login(Login model)
|
||||
{
|
||||
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)
|
||||
{
|
||||
//HttpContext.Session.SetString("tok", "Jarvik");
|
||||
//string t= HttpContext.Session.GetString("tok");
|
||||
|
||||
string risultato = response.Content.ReadAsStringAsync().Result;
|
||||
loginOut = JsonConvert.DeserializeObject<LoginOut>(risultato);
|
||||
HttpContext.Session.SetString("tok", loginOut.Tok);
|
||||
|
||||
|
||||
return RedirectToAction("Index","Home");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Models/AziendaRif.cs
Normal file
23
Models/AziendaRif.cs
Normal file
@ -0,0 +1,23 @@
|
||||
namespace VirtualTask.Models
|
||||
{
|
||||
public class AziendaRif
|
||||
{
|
||||
/// <summary>azienda</summary>
|
||||
public string? piazihoc { get; set; }
|
||||
|
||||
/// <summary>tecnico</summary>
|
||||
public string? picodtec { get; set; }
|
||||
|
||||
/// <summary>tecnico</summary>
|
||||
public string? pirifazi { get; set; }
|
||||
|
||||
/// <summary>Nome azienda collegata</summary>
|
||||
public string? pinomede { get; set; }
|
||||
|
||||
/// <summary>url logo</summary>
|
||||
public string? pilogurl { get; set; }
|
||||
|
||||
/// <summary>Testo rapportino</summary>
|
||||
public string? pitextin { get; set; }
|
||||
}
|
||||
}
|
||||
14
Models/Login.cs
Normal file
14
Models/Login.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace VirtualTask.Models
|
||||
{
|
||||
public class Login
|
||||
{
|
||||
/// <summary>Username</summary>
|
||||
public string? Username { get; set; }
|
||||
|
||||
/// <summary>Password</summary>
|
||||
public string? Password { get; set; }
|
||||
|
||||
/// <summary>Tenant</summary>
|
||||
public string? Tenant { get; set; }
|
||||
}
|
||||
}
|
||||
199
Models/LoginOut.cs
Normal file
199
Models/LoginOut.cs
Normal file
@ -0,0 +1,199 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace VirtualTask.Models
|
||||
{
|
||||
|
||||
/// <summary>Conf (configurazioni app)</summary>
|
||||
public class Conf
|
||||
{
|
||||
/// <summary>pulsante naviga nelle liste</summary>
|
||||
public bool? abilita_naviga { get; set; }
|
||||
|
||||
/// <summary>pulsante telefona nelle liste</summary>
|
||||
public bool? abilita_telefona { get; set; }
|
||||
|
||||
/// <summary>abilita funzione</summary>
|
||||
public bool? abilita_chiamate { get; set; }
|
||||
|
||||
/// <summary>abilita funzione</summary>
|
||||
public bool? abilita_manutenzioni { get; set; }
|
||||
|
||||
/// <summary>barcode abilitato opzionalmente in varie sezioni. Per renderlo obbligatorio vedi flag sott</summary>
|
||||
public bool? abilita_barcode { get; set; }
|
||||
|
||||
/// <summary></summary>
|
||||
public bool? chiamate_accetta { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? chiamate_accetta_barcode { get; set; }
|
||||
|
||||
/// <summary>funziona anche offline</summary>
|
||||
public bool? chiamate_accetta_offline { get; set; }
|
||||
|
||||
/// <summary>abilita funzione</summary>
|
||||
public bool? chiamate_rifiuta { get; set; }
|
||||
|
||||
/// <summary>hiamate_rifiuta_barcode</summary>
|
||||
public bool? chiamate_rifiuta_barcode { get; set; }
|
||||
|
||||
/// <summary>funziona anche offline</summary>
|
||||
public bool? chiamate_rifiuta_offline { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? chiamate_chiudi_barcode { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? chiamate_firma_barcode { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? chiamate_chiudi_salva_barcode { get; set; }
|
||||
|
||||
/// <summary>abilita funzione</summary>
|
||||
public bool? manutenzioni_accetta { get; set; }
|
||||
|
||||
/// <summary>funziona anche offline</summary>
|
||||
public bool? chiamate_chiudi_salva_offline { get; set; }
|
||||
|
||||
/// <summary>abilita funzione</summary>
|
||||
public bool? manutenzioni_rifiuta { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? manutenzioni_accetta_barcode { get; set; }
|
||||
|
||||
/// <summary>funziona anche offline</summary>
|
||||
public bool? manutenzioni_accetta_offline { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? manutenzioni_chiudi_barcode { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? manutenzioni_firma_barcode { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? manutenzioni_chiudi_salva_barcode { get; set; }
|
||||
|
||||
/// <summary>funziona anche offline</summary>
|
||||
public bool? manutenzioni_chiudi_salva_offline { get; set; }
|
||||
|
||||
/// <summary>chiede presena DPI prima di scheda</summary>
|
||||
public bool? dpi_checkbox { get; set; }
|
||||
|
||||
/// <summary> anagrafica visualizza anagrafica</summary>
|
||||
public bool? anagrafica { get; set; }
|
||||
|
||||
/// <summary>abilita stato impianto</summary>
|
||||
public bool? stato_finale { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? descrizione_intervento { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? composizione_impianto { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? note_intervento { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? esito_intervento { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? ora_inizio_fine { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? materiali { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? diritto_chiamata { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? manodopera { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? spese_viaggio { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? tipo_pagamento { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? note_pagamento { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? causale { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? time_sheet { get; set; }
|
||||
|
||||
/// <summary>abilita</summary>
|
||||
public bool? time_sheet_offline { get; set; }
|
||||
|
||||
/// <summary>Costo orario intervento</summary>
|
||||
[Column(TypeName = "decimal(8, 3)")]
|
||||
public decimal? costo_orario { get; set; }
|
||||
|
||||
/// <summary>porta ftp</summary>
|
||||
public int? ftp_port { get; set; }
|
||||
|
||||
/// <summary>barcode obbligatorio</summary>
|
||||
public bool? manutenzioni_rifiuta_barcode { get; set; }
|
||||
|
||||
/// <summary>storico rapportini abilita</summary>
|
||||
public bool? storico { get; set; }
|
||||
|
||||
/// <summary>storico impianto</summary>
|
||||
public bool? storico_tecnico { get; set; }
|
||||
|
||||
/// <summary>Abilita link storico interventi</summary>
|
||||
public bool? storico_interventi { get; set; }
|
||||
|
||||
/// <summary>Abilita link ricerca impianti</summary>
|
||||
public bool? ricerca_impianti { get; set; }
|
||||
|
||||
/// <summary>Abilita link storico impianto (solo per chi gestisce il magazzino)</summary>
|
||||
public bool? storico_impianto { get; set; }
|
||||
|
||||
/// <summary>Calcolo tempo rapportino automatico</summary>
|
||||
public bool? ora_inizio_fine_automatica { get; set; }
|
||||
|
||||
/// <summary>Stampa ora inizio-fine su buono</summary>
|
||||
public bool? stampa_orario { get; set; }
|
||||
|
||||
/// <summary>Stampa intestazione su buono</summary>
|
||||
public string? intestazione_stampa { get; set; }
|
||||
|
||||
/// <summary>Seriale chiamata da usare come teplate per inserire chiamata da app (commessa o normale)</summary>
|
||||
public string? seriale_template_chi { get; set; }
|
||||
|
||||
/// <summary>0=non abilitata 1,2,3=abilitata </summary>
|
||||
public Int16? abilita_inserimento_chiamate { get; set; }
|
||||
}
|
||||
/// <summary>LoginOut (token+user)</summary>
|
||||
public class LoginOut
|
||||
{
|
||||
/// <summary>token</summary>
|
||||
public string? Tok { get; set; }
|
||||
|
||||
/// <summary>token</summary>
|
||||
public string? Tccodice { get; set; }
|
||||
|
||||
/// <summary>token</summary>
|
||||
public string? Tcdescri { get; set; }
|
||||
|
||||
/// <summary>token</summary>
|
||||
public Conf? Config { get; set; }
|
||||
|
||||
/// <summary>storico impianto</summary>
|
||||
public List<AziendaRif>? aziende_coll { get; set; }
|
||||
|
||||
/// <summary>Error Message</summary>
|
||||
public string? err_title { get; set; }
|
||||
|
||||
/// <summary>Error Message detail</summary>
|
||||
public string? err_detail { get; set; }
|
||||
|
||||
/// <summary>Status</summary>
|
||||
public string? err_status_code { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
17
Program.cs
17
Program.cs
@ -3,6 +3,15 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
builder.Services.AddDistributedMemoryCache();
|
||||
|
||||
builder.Services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromSeconds(10);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@ -20,8 +29,12 @@ app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
//app.MapControllerRoute(
|
||||
// name: "default",
|
||||
// pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
pattern: "{controller=Login}/{action=Login}");
|
||||
app.UseSession();
|
||||
app.Run();
|
||||
|
||||
@ -4,5 +4,6 @@
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Welcome</h1>
|
||||
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
42
Views/Login/Login.cshtml
Normal file
42
Views/Login/Login.cshtml
Normal file
@ -0,0 +1,42 @@
|
||||
@model VirtualTask.Models.Login
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Login";
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<h1>Login</h1>
|
||||
|
||||
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Login">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Username" class="control-label"></label>
|
||||
<input asp-for="Username" class="form-control" />
|
||||
<span asp-validation-for="Username" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Password" class="control-label"></label>
|
||||
<input asp-for="Password" class="form-control" />
|
||||
<span asp-validation-for="Password" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Tenant" class="control-label"></label>
|
||||
<input asp-for="Tenant" class="form-control" />
|
||||
<span asp-validation-for="Tenant" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Login" class="btn btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2023 - VirtualTask - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2023 - VirtualTask @ViewBag.Token
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user