-
Notifications
You must be signed in to change notification settings - Fork 3
/
Startup.cs
39 lines (34 loc) · 1.43 KB
/
Startup.cs
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
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;
using System;
using System.Threading.Tasks;
[assembly: OwinStartup(typeof(LMSweb.Startup))]
namespace LMSweb
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// 如需如何設定應用程式的詳細資訊,請瀏覽 https://go.microsoft.com/fwlink/?LinkID=316888
// 說明:
// 利用AuthenticationType欄位來區分登入者是老師還是學生
// 所以要寫分開的2個UseCookieAuthentication
// 實務上很少這樣做,有牽涉到身分(Role)就會像之前一樣登入頁只會有一個,再透過資料庫查詢出登入的使用者是什麼身分
// 也方便和Google、FB...等服務做身分驗證API串接
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Student",
LoginPath = new PathString("/Student/Login"),
ExpireTimeSpan = TimeSpan.FromMinutes(30) //設置cookie保留的時間
});
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Teacher",
LoginPath = new PathString("/Teacher/Login"),
ExpireTimeSpan = TimeSpan.FromMinutes(30)
});
app.MapSignalR();
}
}
}