forked from MatheusPolletti/ProjetoInter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (33 loc) · 1.1 KB
/
Program.cs
File metadata and controls
43 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using ProjetoInter.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.Cookies;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
// Session
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
});
builder.Services.AddDbContext<DbZoologico>(options =>
options.UseMySQL(builder.Configuration.GetConnectionString("DefaultConnection")));
// Autenticação (Cookies)
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/Home/LoginCadastro";
options.AccessDeniedPath = "/Home/LoginCadastro";
});
var app = builder.Build();
// Middlewares
app.UseStaticFiles();
app.UseSession();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=LoginCadastro}/{id?}");
app.MapControllerRoute(
name: "resetarSenha",
pattern: "ResetarSenha",
defaults: new { controller = "ResetarSenha", action = "Index" });
app.Run();