コード例 #1
0
        void IAuthenticationManager.LogIn(HttpContextBase context, IRegisteredUser user, AuthenticationStatus status)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            // Do the HTTP stuff.

            _cookieManager.CreateAuthenticationCookie(context, user);

            // Do the ASP.NET stuff.

            var identity = new RegisteredUserIdentity(user.Id, user.UserType, user.IsActivated)
            {
                FullName   = user.FullName,
                NeedsReset = false,
                User       = user
            };

            // Record it.

            _userSessionsCommand.CreateUserLogin(new UserLogin
            {
                UserId               = user.Id,
                SessionId            = GetSessionId(user.Id, context.Request.UserHostAddress, context.Session),
                IpAddress            = context.Request.UserHostAddress,
                AuthenticationStatus = status
            });
            context.User = new RegisteredUserPrincipal(identity);
        }