/// <summary>
        /// Logs a user into Gigya by calling NotifyLogin.
        /// </summary>
        /// <param name="currentIdentity"></param>
        protected void LoginToGigya(CurrentIdentity currentIdentity)
        {
            var uid = currentIdentity.UID;

            if (string.IsNullOrEmpty(uid))
            {
                _logger.Error("UID hasn't been set for user: "******" so can't login to Gigya");
                return;
            }

            var helper            = new GigyaApiHelper(_settingsHelper, _logger);
            var sessionExpiration = _settingsHelper.SessionExpiration(_settings);
            var apiResponse       = helper.NotifyLogin(uid, sessionExpiration, _settings);

            if (apiResponse == null)
            {
                _logger.Error("Failed to call gigya.accounts.notifyLogin for user " + currentIdentity.Name);
                return;
            }

            var notifyLoginResponse = JsonConvert.DeserializeObject <NotifyLoginResponse>(apiResponse.GetResponseText());

            if (notifyLoginResponse.sessionInfo != null)
            {
                var cookie = new HttpCookie(notifyLoginResponse.sessionInfo.cookieName, notifyLoginResponse.sessionInfo.cookieValue);
                if (sessionExpiration > 0)
                {
                    cookie.Expires = DateTime.UtcNow.AddSeconds(sessionExpiration);
                }

                HttpContext.Current.Response.Cookies.Add(cookie);
                _logger.DebugFormat("Successfully logged in user {0} using gigya.accounts.notifyLogin", currentIdentity.Name);
            }
            else
            {
                _logger.Error("No sessionInfo returned from gigya.accounts.notifyLogin for user " + currentIdentity.Name);
            }
        }
Exemplo n.º 2
0
 public GigyaMembershipHelperBase(GigyaApiHelper apiHelper, GigyaAccountHelperBase gigyaAccountHelper, Logger logger) : base(apiHelper, gigyaAccountHelper, logger)
 {
 }
Exemplo n.º 3
0
 public GigyaMembershipHelperBase(GigyaApiHelper apiHelper, Logger logger)
 {
     _gigyaApiHelper = apiHelper;
     _logger         = logger;
 }
 public GigyaAccountSchemaHelper(GigyaApiHelper <T> apiHelper, T settings)
 {
     _apiHelper           = apiHelper;
     _gigyaModuleSettings = settings;
     _cacheKey            = string.Concat("GigyaAccountSchemaHelper.GetAccountSchema.", settings.ApiKey);
 }