예제 #1
0
        public override IHttpResult OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary <string, string> authInfo)
        {
            authService.Request.RemoveSession();
            // Override session options
            authService.Request.AddSessionOptions(SessionOptions.Temporary);
            // Create new session cookies
            session.Id = authService.Request.Response.CreateSessionIds(authService.Request);

//			authInfo = new Dictionary<string, string>();
//			authInfo.Add("Security", (authService.GetSession() as CustomUserSession).SecurityLevel.ToString());

            try
            {
                session.IsAuthenticated = true;
                session.OnAuthenticated(authService, session, tokens, authInfo);
                AuthEvents.OnAuthenticated(authService.Request, session, authService, tokens, authInfo);
            }
            finally
            {
                authService.SaveSession(session, SessionExpiry);
            }

            return(null);
            //				return base.OnAuthenticated(authService, session, tokens, authInfo);
        }
예제 #2
0
        public void AfterPluginsLoaded(IAppHost appHost)
        {
            var authEvents = appHost.TryResolve <IAuthEvents>();

            if (authEvents == null)
            {
                authEvents = AuthEvents.Count == 0
                    ? new AuthEvents() :
                             AuthEvents.Count == 1
                    ? AuthEvents.First()
                    : new MultiAuthEvents(AuthEvents);

                appHost.GetContainer().Register(authEvents);
            }
            else if (AuthEvents.Count > 0)
            {
                throw new Exception("Registering IAuthEvents via both AuthFeature.AuthEvents and IOC is not allowed");
            }
        }