static int _m_login(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); ThirdPartyLogin gen_to_be_invoked = (ThirdPartyLogin)translator.FastGetCSObj(L, 1); { _eThirdPartyLoginType _login_type; translator.Get(L, 2, out _login_type); string _state = LuaAPI.lua_tostring(L, 3); string _param = LuaAPI.lua_tostring(L, 4); gen_to_be_invoked.login(_login_type, _state, _param); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
private string ThirdPartyId(ThirdPartyLogin thirdPartyLogin) { switch(thirdPartyLogin) { case ThirdPartyLogin.Facebook : return "graph.facebook.com"; default : return null; } }
public void AddThirdPartyLogin(ThirdPartyLogin login, string accessKey, Action<SinozeUser> result) { if(ThirdPartyLogins == null) ThirdPartyLogins = new Dictionary<ThirdPartyLogin, string>(); ThirdPartyLogins.Add(login, accessKey); Module.Find<SinozeUserIdentity>().Resync(this, result); }
//------------------------------------------------------------------------- public static ThirdPartyLogin Instantce() { if (mThirdPartyLogin == null) { mThirdPartyLogin = new ThirdPartyLogin(); } return(mThirdPartyLogin); }
// Edit Record public void EditThirdPartyLogin(ThirdPartyLogin cp) { XElement node = thirdPartyLoginData.Root.Elements("Settings").FirstOrDefault(); node.SetElementValue("GooglePlusId", string.IsNullOrEmpty(cp.GooglePlusId) ? "None" : cp.GooglePlusId); node.SetElementValue("GooglePlusSecretKey", string.IsNullOrEmpty(cp.GooglePlusSecretKey) ? "None" : cp.GooglePlusSecretKey); node.SetElementValue("FacebookId", string.IsNullOrEmpty(cp.FacebookId) ? "None" : cp.FacebookId); node.SetElementValue("FacebookSecretKey", string.IsNullOrEmpty(cp.FacebookSecretKey) ? "None" : cp.FacebookSecretKey); thirdPartyLoginData.Save(HttpContext.Current.Server.MapPath("~/App_Data/AdminSettings.xml")); }
public ActionResult Edit() { if (((CustomPrincipal)User).IsAdmin) { ThirdPartyLogin cp = _repository.GetThirdPartyLogin(); if (cp == null) { return(RedirectToAction("Index")); } return(View(cp)); } else { return(RedirectToAction("Index", "Home")); } }
static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 1) { ThirdPartyLogin gen_ret = new ThirdPartyLogin(); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to ThirdPartyLogin constructor!")); }
public ActionResult Edit(ThirdPartyLogin cp) { if (((CustomPrincipal)User).IsAdmin) { if (ModelState.IsValid) { try { _repository.EditThirdPartyLogin(cp); return(RedirectToAction("Index", "Admin")); } catch (Exception ex) { ModelState.AddModelError("", "Error editing record. " + ex.Message); } } } return(RedirectToAction("Index", "Home")); }
static int _m_Instantce_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { ThirdPartyLogin gen_ret = ThirdPartyLogin.Instantce( ); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_initLogin(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); ThirdPartyLogin gen_to_be_invoked = (ThirdPartyLogin)translator.FastGetCSObj(L, 1); { string _app_id = LuaAPI.lua_tostring(L, 2); gen_to_be_invoked.initLogin(_app_id); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public void ConfigureAuth(IAppBuilder app) { DataProtectionProvider = app.GetDataProtectionProvider(); var UseActiveDirectory = System.Configuration.ConfigurationManager.AppSettings["UseActiveDirectory"]; //CommonFunction.Instance.UseActiveDirectory(); if (!Convert.ToBoolean(UseActiveDirectory)) { // Enable the application to use a cookie to store information for the signed in user //set session time out value from appsetting ApplicationContext db = new ApplicationContext(new SystemUser()); var appSettings = db.AppSettings; string timeout = appSettings.Where(p => p.Key == "ApplicationSessionTimeOut").FirstOrDefault().Value; string AppUrl = appSettings.Where(p => p.Key == "AppURL").FirstOrDefault().Value; Int64 TimeOutValue = 525600; if (!string.IsNullOrEmpty(timeout)) { if (Int64.TryParse(timeout, out TimeOutValue)) { if (TimeOutValue == 0) { TimeOutValue = Convert.ToInt64(525600); } } else { TimeOutValue = 525600; } } // app.UseCookieAuthentication(new CookieAuthenticationOptions { CookieName = AppUrl, ExpireTimeSpan = TimeSpan.FromMinutes(TimeOutValue), AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); // Use a cookie to temporarily store information about a user logging in with a third party login provider app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); ThirdPartyLoginRepository thirdPartyLoginRepository = new ThirdPartyLoginRepository(); ThirdPartyLogin thirdPartyLogin = thirdPartyLoginRepository.GetThirdPartyLogin(); //Google // Uncomment the following lines to enable logging in with third party login providers GooglePlusAuthenticationOptions google = new GooglePlusAuthenticationOptions(); google.ClientId = thirdPartyLogin.GooglePlusId; google.ClientSecret = thirdPartyLogin.GooglePlusSecretKey; //commmented to use google authentication from GooleAuthApp app.UseGooglePlusAuthentication(google); //Yahoo OAuthWebSecurity.RegisterYahooClient(); app.UseOpenIDAuthentication("/open.login.yahooapis.com/openid/op/auth", "Yahoo"); //Facebook var x = new FacebookAuthenticationOptions(); x.Scope.Add("email"); x.Scope.Add("friends_about_me"); x.Scope.Add("friends_photos"); x.AppId = thirdPartyLogin.FacebookId; x.AppSecret = thirdPartyLogin.FacebookSecretKey; x.Provider = new FacebookAuthenticationProvider() { OnAuthenticated = async context => { //Get the access token from FB and store it in the database and //use FacebookC# SDK to get more information about the user context.Identity.AddClaim( new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken)); } }; x.SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie; app.UseFacebookAuthentication(x); } }