Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int authorId = 0;
            AuthenticationModel oAuthenticationModel = SessionService.GetCurrentUser();

            if (oAuthenticationModel.Authenticated && oAuthenticationModel.oPublisherInfo != null)
            {
                authorId = oAuthenticationModel.oPublisherInfo.Id;
            }

            MessageBox1.ClearMessage();

            if (!IsPostBack)
            {
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AuthenticationModel oAuthenticationModel = SessionService.GetCurrentUser();

            if (oAuthenticationModel.Authenticated && oAuthenticationModel.oPublisherInfo != null)
            {
                StudentId = oAuthenticationModel.oPublisherInfo.Id;
            }

            MessageBox1.ClearMessage();
            AttachmentPath = System.Configuration.ConfigurationManager.AppSettings["BookListAttachmentPath"];
            try
            {
            }
            catch (Exception ex)
            {
                MessageBox1.ShowMessage(ex.Message, Constants.MesageType.Error);
            }
        }
Esempio n. 3
0
 public void Logout()
 {
     SessionService.Remove(SessionService.Keys.AuthenticationInfo);
 }
Esempio n. 4
0
 public static bool Remove(Keys key)
 {
     return(SessionService.Save <object>(key, null));
 }
Esempio n. 5
0
        void BasePage_Init(object sender, EventArgs e)
        {
            var SiteIsLive = System.Configuration.ConfigurationManager.AppSettings["SiteIsLive"];

            if (SiteIsLive.ToLower() == "no")
            {
                Response.Redirect("~/500.html");
            }



            var restrictionAllowed = System.Configuration.ConfigurationManager.AppSettings["IPRestrictionEnabaled"];

            if (restrictionAllowed == "yes")
            {
                string message       = "";
                var    AccessAllowed = this.VerifyAccess(ref message);

                if (AccessAllowed == false)
                {
                    Response.Redirect("~/400.html?" + message);
                }
            }

            var AuthenticationModel = SessionService.GetCurrentUser();

            if (AuthenticationModel.Authenticated == false)
            {
                //Response.Redirect("~/Login.aspx");
            }

            // authentication checks if user is logged in or not
            var isLoggedIn = false;

            // authorization checks if user is admin, teacher or student
            var isAuthorized        = false;
            var isAuthenticatedPage = false;

            var attributes = this.GetType().GetCustomAttributes(true);
            var loginInfo  = this.LoginInfo;



            //foreach (var attribute in attributes)
            //{
            //    if (attribute is LoggedInAttribute)
            //    {
            //       // if we have found LoggedInAttribute
            //        // then it means the page is authenticated
            //        // and we must check user authentication and authorization
            //        isAuthenticatedPage = true;

            //        var allowedAccountTyes = ((LoggedInAttribute)attribute).AllowedAccountTyes;

            //        // guest users should not
            //        // be allowed to come on this page
            //        if (loginInfo.Authenticated == true)
            //        {
            //            isLoggedIn = true;
            //        }
            //        else
            //        {
            //            isLoggedIn = false;
            //            break;
            //        }



            //        // check for authorization
            //        // if user is admin so he can only browse admin pages.
            //        if (allowedAccountTyes.Contains(Backbone.Constants.UserType.Admin))
            //        {
            //            if (loginInfo.AccountType == Backbone.Constants.UserType.Admin)
            //            {
            //                isAuthorized = true;
            //                break;
            //            }
            //        }
            //        else if (allowedAccountTyes.Contains(Backbone.Constants.UserType.Author))
            //        {
            //            if (loginInfo.AccountType == Backbone.Constants.UserType.Author)
            //            {
            //                isAuthorized = true;
            //                break;
            //            }
            //        }
            //        else
            //        {
            //            if (loginInfo.AccountType == Backbone.Constants.UserType.Student)
            //            {
            //                isAuthorized = true;
            //                break;
            //            }
            //        }
            //    }
            //    else if (attribute is PermissionsAttribute)
            //    {
            //        // if we have found PermissionsAttribute
            //        // then it means the page is authenticated
            //        // and we must check user authentication and authorization
            //        isAuthenticatedPage = true;


            //        var requiredPermissions = ((PermissionsAttribute)attribute).RequiredPermissions.Select(x=> x.GetHashCode());

            //        // guest users should not
            //        // be allowed to come on this page
            //        if (loginInfo.Authenticated == false)
            //        {
            //            isLoggedIn = false;
            //            break;
            //        }
            //        else
            //        {
            //            isLoggedIn = true;
            //            var permissions = loginInfo.Permissions;

            //           var aaa=  permissions.Where(s=>s.Id== 63).FirstOrDefault();
            //           if (aaa != null)
            //           {

            //           }

            //            var found = permissions.Where(x => requiredPermissions.Contains(x.Id)).ToList();
            //            if (found != null && found.Count > 0)
            //            {
            //                isAuthorized = true;
            //                break;
            //            }
            //        }
            //    }
            //}


            if (isAuthenticatedPage == true)
            {
                // if user is not logged in
                // then redirect to login page.
                if (isLoggedIn == false)
                {
                    Response.Redirect("~/Login.aspx");
                }
                else
                {
                    if (isAuthorized == false)
                    {
                        Response.Redirect("~/AccessDenied.aspx");
                    }
                }
            }
        }