Exemplo n.º 1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.UserManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            if (!Page.IsPostBack)
            {
                cmbUserTitle.DataSource     = UserGuiHelper.GetAllUserTitles();
                cmbUserTitle.DataTextField  = "UserTitleDescription";
                cmbUserTitle.DataValueField = "UserTitleID";
                cmbUserTitle.DataBind();
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (SessionAdapter.GetAdminId() != null && SessionAdapter.GetInstructorId() != null)
     {
         hypOffering.Visible                       =
             hypStudent.Visible                    =
                 hypInstructor.Visible             =
                     hypCourse.Visible             =
                         hypSemester.Visible       =
                             hypAttendance.Visible =
                                 hypGrade.Visible  = true;
         hypLogInLogOut.Text                       = "Log Out";
     }
     else if (SessionAdapter.GetAdminId() != null)
     {
         hypOffering.Visible                 =
             hypStudent.Visible              =
                 hypInstructor.Visible       =
                     hypCourse.Visible       =
                         hypSemester.Visible = true;
         hypLogInLogOut.Text                 = "Log Out";
     }
     else if (SessionAdapter.GetInstructorId() != null)
     {
         hypAttendance.Visible =
             hypGrade.Visible  = true;
         hypLogInLogOut.Text   = "Log Out";
     }
     else
     {
         hypLogInLogOut.Text = "Log In";
     }
 }
Exemplo n.º 3
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            firebaseAnalytics = FirebaseAnalytics.GetInstance(Context);
            base.OnCreate(savedInstanceState);

            var sessions = Queries.AllNotUploadedInterviewSessionsForActiveUser();

            sessions = sessions.FindAll(t => !t.IsUploaded);
            adapter  = new SessionAdapter(sessions);
            Activity.FindViewById <RecyclerView>(Resource.Id.sessions).SetAdapter(adapter);

            var sessionsUploadButton = Activity.FindViewById <AppCompatButton>(Resource.Id.upload_sessions);

            ShowHideInstructions();

            sessionsUploadButton.Click += (s, e) => UploadIfNot(0, true);
            adapter.SessionClicked     += (s, p) => UploadIfNot(p, false);

            var prefs = PreferenceManager.GetDefaultSharedPreferences(Activity.ApplicationContext);

            // Ensures that the dialog only shows after completing a recording.
            if (prefs.GetBoolean("SESSION_RECORDED", false))
            {
                prefs.Edit().PutBoolean("SESSION_RECORDED", false).Commit();
                ShowDebriefingDialog();
            }
        }
Exemplo n.º 4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            if (!Page.IsPostBack)
            {
                // bind the Roles repeater to a dataview with all sections.
                DataView rolesWithStatistics = SecurityGuiHelper.GetAllRolesWithStatisticsAsDataView();

                rpRoles.DataSource = rolesWithStatistics;
                rpRoles.DataBind();
            }
        }
Exemplo n.º 5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _roleID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["RoleID"]);

            if (!Page.IsPostBack)
            {
                // get the role and show the description
                RoleEntity role = SecurityGuiHelper.GetRole(_roleID);

                if (!role.IsNew)
                {
                    lblRoleDescription.Text = role.RoleDescription;
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            bool userHasAccess = SessionAdapter.HasSystemActionRight(ActionRights.UserManagement);

            if (!userHasAccess)
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            if (Page.IsPostBack)
            {
                GetViewState();
                SetToNames();
            }
            else
            {
                SetViewState();
            }
        }
Exemplo n.º 7
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _roleID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["RoleID"]);

            if (!Page.IsPostBack)
            {
                // Get Role
                RoleEntity role = SecurityGuiHelper.GetRole(_roleID);
                _roleDescription = role.RoleDescription;

                // bind the users listbox to an entitycollection with all users.
                UserCollection users = UserGuiHelper.GetAllUsersNotInRole(_roleID);

                lbxUsers.DataSource     = users;
                lbxUsers.DataTextField  = "NickName";
                lbxUsers.DataValueField = "UserID";
                lbxUsers.DataBind();
            }
        }
Exemplo n.º 8
0
        private void OnPlayerFinished(object state)
        {
            object[] stateParams        = (object[])state;
            int      currentChallengeID = (int)stateParams[0];
            PlayerFinishEventArgs e     = (PlayerFinishEventArgs)stateParams[1];

            if (e.TimeOrScore > 0)
            {
                uint?oldPosition, newPosition;
                bool newBest;
                RecordAdapter.CheckAndWriteNewRecord(e.Login, currentChallengeID, e.TimeOrScore, out oldPosition, out newPosition, out newBest);

                if (newBest)
                {
                    string nickname = GetNickname(e.Login);

                    if (nickname != null && newPosition <= Settings.MaxRecordsToReport && currentChallengeID == CurrentChallengeID)
                    {
                        DetermineLocalRecords();
                        OnPlayerNewRecord(e.Login, nickname, e.TimeOrScore, oldPosition, newPosition);
                    }
                }

                SessionAdapter.AddSession(e.Login, currentChallengeID, Convert.ToUInt32(e.TimeOrScore));
            }
        }
Exemplo n.º 9
0
 public ActionResult SetStore(String storeCode)
 {
     try
     {
         // Check the length of the store code. Limiting to 50 characters.
         if (storeCode.Length > 50)
         {
             throw new Exception("Bad store code");
         }
         // Check the store code to see if it's real. SQL Injection is handled by using a stored procedure.
         List <StoreInfo> storeList = DBAdapter.getInstance().GetStoreInfoByStoreCode(storeCode);
         // If the store code is a real store code, list size will be > 0
         if (storeList.Count() > 0)
         {
             // real store, set the cookie, and redirect to login page
             SessionAdapter.getInstance().SetCurrentStore(storeList[0], Response);
         }
         else
         {
             // not a real store, redirect to ChooseStore
             throw new Exception("Bad store code");
         }
     } catch (Exception e)
     {
         return(RedirectToAction("ChooseStore", "Login"));
     }
     // clear last logged in user.
     SessionAdapter.getInstance().SetLastLoggedInUser(null, this.Response);
     return(this.RedirectToAction("Index", "Login"));
 }
Exemplo n.º 10
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            if (!Page.IsPostBack)
            {
                // Read all the current existing forums and their section names.
                ForumsWithSectionNameTypedList forumsWithSectionNames = ForumGuiHelper.GetAllForumsWithSectionNames();
                rpForums.DataSource = forumsWithSectionNames;
                rpForums.DataBind();
            }
        }
Exemplo n.º 11
0
        public ActionResult LogUserIn(LoginModel login)
        {
            string adPath = ConfigurationManager.AppSettings["connection_ldap"]; //Path to your LDAP directory server

            ViewBag.ldapaddress = adPath;
            LdapAuthentication adAuth = new LdapAuthentication(adPath);

            try
            {
                bool authed = false;
                authed = adAuth.IsAuthenticated("flinc", login.UserName, login.Password);
                if (authed)
                {
                    // authorized
                    User loggedInUser = DBAdapter.getInstance().GetUserByUsername(login.UserName);
                    SessionAdapter.getInstance().LoggedInUser = loggedInUser;
                    // Set the cookie
                    FormsAuthentication.SetAuthCookie(login.UserName, true);
                    ViewBag.hasBeenLoggedIn = "true";
                }
            }
            catch (Exception ex)
            {
                // fail
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
                ViewBag.hasBeenLoggedIn = "false";
            }
            return(View());
        }
Exemplo n.º 12
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            bool hasAccess = SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement);

            if (!hasAccess)
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            if (!Page.IsPostBack)
            {
                cldStartDate.SelectedDate = DateTime.Now;
                cldStartDate.VisibleDate  = DateTime.Now;
            }
        }
Exemplo n.º 13
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // can perform system management tasks. Visualize menu
                phSections.Visible = true;
                phForums.Visible   = true;
                phSystem.Visible   = true;
            }

            if (SessionAdapter.HasSystemActionRight(ActionRights.UserManagement))
            {
                // can perform user management tasks, visualize menu
                phUsers.Visible = true;
            }

            if (SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement))
            {
                // can perform security management tasks, visualize menu.
                phSecurity.Visible = true;
            }

            // switch off the link back to the admin menu as this page holds the admin menu.
            SD.HnD.GUI.Admin.Header pageHeader = (SD.HnD.GUI.Admin.Header)Master.FindControl("_pageHeader");
            pageHeader.MenuReturnLinkVisible = false;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Handler for the selectclicked event of the finduser control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SelectClickedHandler(object sender, System.EventArgs e)
        {
            phDeleteResult.Visible = false;

            List <int> selectedUserIDs = userFinder.SelectedUserIDs;

            if (selectedUserIDs.Count < 0)
            {
                // nothing selected, return
                return;
            }

            // just use the first selected user
            int selectedUserID = selectedUserIDs[0];

            if ((selectedUserID == 0) || (selectedUserID == SessionAdapter.GetUserID()))
            {
                // can't delete anonymous coward or him/herself
                return;
            }

            UserEntity user = UserGuiHelper.GetUser(selectedUserID);

            lblNickname.Text   = user.NickName;
            lblUserID.Text     = user.UserID.ToString();
            phUserInfo.Visible = true;
        }
Exemplo n.º 15
0
 public ActionResult Index()
 {
     @ViewBag.customerTypes   = this.getCustomerTypes();
     @ViewBag.user            = SessionAdapter.getInstance().LoggedInUser;
     @ViewBag.associates      = DBAdapter.getInstance().GetAllUsers();
     @ViewBag.associateImages = this.PrepareAssociateImages(@ViewBag.associates);
     return(View());
 }
Exemplo n.º 16
0
        public ActionResult GetSiteAreas()
        {
            ProductService  serv      = WebServiceUtils.GetEndpointService <ProductService>(ProductServiceInfo.ENDPOINT_NAME);
            List <SiteArea> siteAreas = serv.SiteAreasForStoreCode(SessionAdapter.getInstance().GetCurrentStore(this.Request));

            ViewBag.siteAreas = siteAreas;
            return(View());
        }
Exemplo n.º 17
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            if (!Page.IsPostBack)
            {
                // load the data into the dropdown boxes.
                RoleCollection allRoles = SecurityGuiHelper.GetAllRoles();

                cbxDefaultRoleNewUsers.DataSource     = allRoles;
                cbxDefaultRoleNewUsers.DataTextField  = "RoleDescription";
                cbxDefaultRoleNewUsers.DataValueField = "RoleID";
                cbxDefaultRoleNewUsers.DataBind();

                cbxAnonymousUserRole.DataSource     = allRoles;
                cbxAnonymousUserRole.DataTextField  = "RoleDescription";
                cbxAnonymousUserRole.DataValueField = "RoleID";
                cbxAnonymousUserRole.DataBind();

                UserTitleCollection userTitles = UserGuiHelper.GetAllUserTitles();

                cbxDefaultUserTitleNewUsers.DataSource     = userTitles;
                cbxDefaultUserTitleNewUsers.DataTextField  = "UserTitleDescription";
                cbxDefaultUserTitleNewUsers.DataValueField = "UserTitleID";
                cbxDefaultUserTitleNewUsers.DataBind();

                // preselect the current values of the system parameters.
                SystemDataEntity systemData = CacheManager.GetSystemData();

                cbxDefaultRoleNewUsers.SelectedValue      = systemData.DefaultRoleNewUser.ToString();
                cbxAnonymousUserRole.SelectedValue        = systemData.AnonymousRole.ToString();
                cbxDefaultUserTitleNewUsers.SelectedValue = systemData.DefaultUserTitleNewUser.ToString();

                tbxActiveThreadsThreshold.Text             = systemData.HoursThresholdForActiveThreads.ToString();
                tbxMinNumberOfNonStickyVisibleThreads.Text = systemData.MinNumberOfNonStickyVisibleThreads.ToString();
                tbxMinNumberOfThreadsToFetch.Text          = systemData.MinNumberOfThreadsToFetch.ToString();
                tbxPageSizeInSearchResults.Text            = systemData.PageSizeSearchResults.ToString();

                chkSendReplyNotifications.Checked = systemData.SendReplyNotifications;

                ViewState.Add("ID", systemData.ID);
            }
        }
Exemplo n.º 18
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // If the user doesn't have any access rights to management stuff, the user should
     // be redirected to the default of the global system.
     if (!SessionAdapter.HasSystemActionRights())
     {
         // doesn't have system rights. redirect.
         Response.Redirect("../Default.aspx", true);
     }
 }
Exemplo n.º 19
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            firebaseAnalytics = FirebaseAnalytics.GetInstance(Context);
            base.OnCreate(savedInstanceState);

            var sessions = Queries.AllNotUploadedInterviewSessionsForActiveUser();

            sessions = sessions.FindAll(t => !t.IsUploaded);
            adapter  = new SessionAdapter(sessions);
            Activity.FindViewById <RecyclerView>(Resource.Id.sessions).SetAdapter(adapter);

            FirebaseAnalytics.GetInstance(Activity).SetUserProperty(
                "uploadQueueCount",
                sessions.Count().ToString());

            var sessionsUploadButton = Activity.FindViewById <AppCompatButton>(Resource.Id.upload_sessions);

            ShowHideInstructions();

            sessionsUploadButton.Click += (s, e) => UploadIfNot(0, true);
            adapter.SessionClicked     += (s, p) => UploadIfNot(p, false);

            var prefs = PreferenceManager.GetDefaultSharedPreferences(Activity.ApplicationContext);

            // Ensures that the dialog only shows after completing a recording.
            if (prefs.GetBoolean("SESSION_RECORDED", false))
            {
                // Get epoch time
                TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
                int      secondsSinceEpoch = (int)t.TotalSeconds;

                FirebaseAnalytics.GetInstance(Activity).SetUserProperty(
                    "lastUploadAdded",
                    secondsSinceEpoch.ToString());

                if (IsConnectedToWifi())
                {
                    var suppressAsync = UploadSessions(0, true);
                }
                else
                {
                    new AlertDialog.Builder(Activity)
                    .SetTitle(StringResources.sessions_ui_wifiwarning_title)
                    .SetMessage(StringResources.sessions_ui_wifiwarning_message)
                    .SetNegativeButton(StringResources.sessions_ui_wifiwarning_cancel, (a, b) => { })
                    .SetPositiveButton(StringResources.sessions_ui_wifiwarning_confirm, (a, b) =>
                    {
                        var suppressAsync = UploadSessions(0, true);
                    })
                    .Show();
                }

                prefs.Edit().PutBoolean("SESSION_RECORDED", false).Commit();
            }
        }
Exemplo n.º 20
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            string   username      = tbxUsername.Text;
            string   password      = tbxPassword.Text;
            DateTime lastLoginDate = DateTime.Now;

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(tbxPassword.Text))
            {
                vs1.HeaderText = "Please enter username and password";
                return;
            }

            //users are faculty
            var users = UserGuiHelper.GetUserUsingUserNamePasswordAsDataTable(username, password);

            if (users.Rows.Count > 0)
            {
                var    user         = users.Rows[0];
                bool   isAdmin      = (bool)user["IsAdmin"];
                bool   isInstructor = (bool)user["IsInstructor"];
                int    userId       = int.Parse(users.Rows[0]["Id"].ToString());
                string userName     = users.Rows[0]["FullName"].ToString();

                if (isAdmin && isInstructor)
                {
                    SessionAdapter.SetAdminId(userId);
                    SessionAdapter.SetInstructorId(userId);
                    SessionAdapter.SetUserName(userName);
                    Response.Redirect("Student.aspx");
                }
                else if (isAdmin)
                {
                    SessionAdapter.SetAdminId(userId);
                    SessionAdapter.SetUserName(userName);
                    Response.Redirect("Student.aspx");
                }
                else if (isInstructor)
                {
                    SessionAdapter.SetInstructorId(userId);
                    SessionAdapter.SetUserName(userName);
                    Response.Redirect("Attendance.aspx");
                }
                else
                {
                }
            }
            else
            {
                ErrorMessage.Visible = true;
                FailureText.Text     = "Username or password is incorrect! Please try again!";
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _roleID = 0;

            if (!Page.IsPostBack)
            {
                // Get all roles
                RoleCollection roles = SecurityGuiHelper.GetAllRoles();

                cbxRoles.DataSource     = roles;
                cbxRoles.DataTextField  = "RoleDescription";
                cbxRoles.DataValueField = "RoleID";
                cbxRoles.DataBind();

                if (cbxRoles.Items.Count > 0)
                {
                    cbxRoles.Items[0].Selected = true;
                    _roleID = HnDGeneralUtils.TryConvertToInt(cbxRoles.SelectedItem.Value);
                }

                // get the audit actions
                AuditActionCollection auditActions = SecurityGuiHelper.GetAllAuditActions();

                cblAuditActions.DataSource     = auditActions;
                cblAuditActions.DataTextField  = "AuditActionDescription";
                cblAuditActions.DataValueField = "AuditActionID";
                cblAuditActions.DataBind();

                // Reflect action rights for current selected forum for this role
                ReflectCurrentAuditActions();
            }
            else
            {
                _roleID = HnDGeneralUtils.TryConvertToInt(cbxRoles.SelectedItem.Value);
            }
        }
Exemplo n.º 22
0
 public static bool Auth(HttpRequest request)
 {
     if (request.Cookies["Trackify-Auth"] != null)
     {
         if (request.Cookies["Trackify-UId"] != null)
         {
             int tempUid = SessionAdapter.ValidateUser((request.Cookies["Trackify-Auth"]));
             if (tempUid.ToString().Equals(request.Cookies["Trackify-UId"]))
             {
                 Console.WriteLine("AUTHENTICATED");
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 23
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _sectionID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["SectionID"]);

            if (!Page.IsPostBack)
            {
                // Get the section directly from the DB, instead from the in-memory cache
                SectionEntity section = SectionGuiHelper.GetSection(_sectionID);

                // Show results in the labels
                if (section != null)
                {
                    // Section found
                    // Get the forums in the section
                    ForumCollection forums = ForumGuiHelper.GetAllForumsInSection(_sectionID);
                    if (forums.Count > 0)
                    {
                        // section has forums. User is not able to delete the section. Show error message plus
                        // disable delete button
                        lblRuleError.Visible = true;
                        btnDelete.Disabled   = true;
                    }
                    lblSectionName.Text        = section.SectionName;
                    lblSectionDescription.Text = section.SectionDescription;
                }
                else
                {
                    // the section doesn't exist anymore
                    Response.Redirect("ModifyDeleteSection.aspx", true);
                }
            }
        }
Exemplo n.º 24
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright;
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _forumID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["ForumID"]);

            if (!Page.IsPostBack)
            {
                // Get the forum
                try
                {
                    ForumEntity forum = ForumGuiHelper.GetForum(_forumID);

                    // Show results in the labels
                    if (forum != null)
                    {
                        // the forum exists
                        lblForumName.Text        = forum.ForumName;
                        lblForumDescription.Text = forum.ForumDescription;
                    }
                    else
                    {
                        // the forum doesn't exist anymore
                        Response.Redirect("ModifyDeleteForum.aspx", true);
                    }
                }
                catch (Exception ex)
                {
                    // Bubble
                    throw ex;
                }
            }
        }
Exemplo n.º 25
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _roleID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["RoleID"]);

            if (!Page.IsPostBack)
            {
                // get the role and show the description
                RoleEntity role = SecurityGuiHelper.GetRole(_roleID);
                if (role != null)
                {
                    tbxRoleDescription.Text = role.RoleDescription;
                }

                // get the system rights
                ActionRightCollection systemActionRights = SecurityGuiHelper.GetAllSystemActionRights();

                cblSystemRights.DataSource     = systemActionRights;
                cblSystemRights.DataTextField  = "ActionRightDescription";
                cblSystemRights.DataValueField = "ActionRightID";
                cblSystemRights.DataBind();

                // get the action rights set for this role
                RoleSystemActionRightCollection systemActionRightRoleCombinations = SecurityGuiHelper.GetSystemActionRightRolesForRole(_roleID);

                // check the checkboxes in the cblSystemRights list if the value matches a row in the datatable
                foreach (RoleSystemActionRightEntity currentEntity in systemActionRightRoleCombinations)
                {
                    cblSystemRights.Items.FindByValue(currentEntity.ActionRightID.ToString()).Selected = true;
                }
            }
        }
Exemplo n.º 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            bool userHasAccess = SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement);

            if (!userHasAccess)
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }
        }
Exemplo n.º 27
0
        public ActionResult Index()
        {
            StoreInfo store = SessionAdapter.getInstance().GetCurrentStore(Request);

            try
            {
                if (store.StoreCode == null)
                {
                    throw new Exception("Storecode is null, we need storecode to continue");
                }
                this.users          = DBAdapter.getInstance().GetUsersByStoreCode(store.StoreCode);
                @ViewBag.users      = this.users;
                @ViewBag.storeCodes = this.storeCodes;
            }
            catch (Exception e)
            {
                return(this.RedirectToAction("ChooseStore", "Login"));
            }
            return(View());
        }
Exemplo n.º 28
0
        public async Task <IActionResult> Callback(string code, string state, string error)
        {
            if (error != null)
            {
                return(RedirectToRoute("/login/unauthorized"));
            }
            CallbackResponse cr;

            using (var client = new HttpClient())
            {
                var values = new Dictionary <string, string>
                {
                    { "client_id", client_id },
                    { "client_secret", client_secret },
                    { "grant_type", "authorization_code" },
                    { "code", code },
                    { "redirect_uri", redirect_uri }
                };
                var content = new FormUrlEncodedContent(values);

                var response = await client.PostAsync("https://accounts.spotify.com/api/token", content);

                var responseString = await response.Content.ReadAsStringAsync();

                cr = JsonConvert.DeserializeObject <CallbackResponse>(responseString);
            }
            string responseJson = await SpotifyApi.ApiManager.Auth_Get("https://api.spotify.com/v1/me", cr.access_token);

            Console.WriteLine(responseJson);
            //save user on sign-up
            User CurrentUser = UserAdapter.ParseUserJson(responseJson, 1);

            //generate and save session information
            CurrentUser = UserAdapter.GetUserBySpotifyUserId(CurrentUser.UserId);
            Session s = SessionAdapter.GenerateSession(CurrentUser.Id);

            //Set the cookies value
            Response.Cookies.Append("Trackify-Auth", s.Code);
            Response.Cookies.Append("Trackify-UId", s.UserId.ToString());
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 29
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _sectionID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["SectionID"]);

            if (!Page.IsPostBack)
            {
                // Load the section directly from the database and show it in the textboxes
                SectionEntity section = SectionGuiHelper.GetSection(_sectionID);

                if (section != null)
                {
                    // show it
                    tbxSectionName.Value       = section.SectionName;
                    tbxSectionDescription.Text = section.SectionDescription;
                    tbxOrderNo.Text            = section.OrderNo.ToString();
                }
                else
                {
                    // not found
                    Response.Redirect("Default.aspx", true);
                }
            }
        }
Exemplo n.º 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            bool userHasAccess = SessionAdapter.HasSystemActionRight(ActionRights.UserManagement);

            if (!userHasAccess)
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            // set these form variables to their required values, so the InsertParameters of the datasource control can pick them up when a new ip ban
            // entity is inserted.
            _userID.Value      = SessionAdapter.GetUserID().ToString();
            _currentDate.Value = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");
        }