using System; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.Owin; using Microsoft.Owin; using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Security.Google; using Owin; using Chruch.Net.Models; using Microsoft.AspNet.Identity.EntityFramework; namespace Chruch.Net { public partial class Startup { // 如需設定驗證的詳細資訊,請瀏覽 https://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // 設定資料庫內容、使用者管理員和登入管理員,以針對每個要求使用單一執行個體 // 讓應用程式使用 Cookie 儲存已登入使用者的資訊 // 並使用 Cookie 暫時儲存使用者利用協力廠商登入提供者登入的相關資訊; // 在 Cookie 中設定簽章 app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // 讓應用程式在雙因素驗證程序中驗證第二個因素時暫時儲存使用者資訊。 app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // 讓應用程式記住第二個登入驗證因素 (例如電話或電子郵件)。 // 核取此選項之後,將會在用來登入的裝置上記住登入程序期間的第二個驗證步驟。 // 這類似於登入時的 RememberMe 選項。 app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); // 註銷下列各行以啟用利用協力廠商登入提供者登入 //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() //{ // ClientId = "", // ClientSecret = "" //}); CreateRolesandUsers(); } private void CreateRolesandUsers() { } } }