示例#1
0
 protected void OnLoggingOut(object sender, LoginCancelEventArgs e)
 {
     string connectionString = ConfigurationManager.ConnectionStrings["BlogEntities"].ConnectionString;
     IUserRepository userRepository = new EFUserRepository(connectionString);
     ISecurityManager securityManager = new FormsSecurityManager(userRepository);
     securityManager.Logout();
 }
示例#2
0
        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["BlogEntities"].ConnectionString;
            IUserRepository userRepository = new EFUserRepository(connectionString);
            ISecurityManager securityManager = new FormsSecurityManager(userRepository);

            securityManager.RefreshPrincipal();
        }
示例#3
0
        public void ProcessRequest(HttpContext context)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["BlogEntities"].ConnectionString;
            IUserRepository userRepository = new EFUserRepository(connectionString);
            IPictureRepository pictureRepository = new EFPictureRepository(connectionString);
            int userId = Convert.ToInt32(HttpContext.Current.Request["userId"]);
            User user = userRepository.GetUser(userId);
            Picture picture = pictureRepository.GetPicture(user.PictureId);
            context.Response.ContentType = picture.ImageMimeType;
            byte[] data = picture.FileData;

            using (MemoryStream ms = new MemoryStream())
            {
                ms.Write(data, 0, data.Length);
                ms.WriteTo(HttpContext.Current.Response.OutputStream);
            }
        }
示例#4
0
        protected void lgAuth_OnLoggingIn(object sender, LoginCancelEventArgs e)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["BlogEntities"].ConnectionString;
            IUserRepository userRepository = new EFUserRepository(connectionString);
            ISecurityManager securityManager = new FormsSecurityManager(userRepository);
            string userName = lgAuth.UserName;
            string password = lgAuth.Password;

            if (securityManager.Login(userName, password) == true)
            {

            }
            else
            {

            }
        }