private void CreateUserNameField(HtmlGenericControl container) { using (HtmlGenericControl field = HtmlControlHelper.GetField()) { using (HtmlGenericControl label = HtmlControlHelper.GetLabel(Resources.Titles.Username, "UserNameInputText")) { field.Controls.Add(label); } using (HtmlGenericControl iconInput = HtmlControlHelper.GetLeftIconInput()) { using (HtmlInputText userNameInputText = new HtmlInputText()) { userNameInputText.ID = "UserNameInputText"; userNameInputText.Attributes.Add("readonly", "readonly"); userNameInputText.Value = CurrentSession.GetUserName(); iconInput.Controls.Add(userNameInputText); } using (HtmlGenericControl icon = HtmlControlHelper.GetIcon("user icon")) { iconInput.Controls.Add(icon); } field.Controls.Add(iconInput); } container.Controls.Add(field); } }
public static void RequestLogOnPage() { FormsAuthentication.SignOut(); Log.Information("User {UserName} was signed off.", CurrentSession.GetUserName()); Log.Debug("Clearing Http Cookies."); foreach (string cookie in HttpContext.Current.Request.Cookies.AllKeys) { HttpContext.Current.Request.Cookies.Remove(cookie); Log.Verbose("Cleared cookie: {Cookie}.", cookie); } string currentPage = HttpContext.Current.Request.Url.AbsolutePath; Log.Verbose("Current page is {CurrentPage}.", currentPage); Page page = HttpContext.Current.Handler as Page; if (page == null) { return; } string loginUrl = (page).ResolveUrl(FormsAuthentication.LoginUrl); if (currentPage != loginUrl) { FormsAuthentication.RedirectToLoginPage(currentPage); Log.Information("Redirected to login page."); } }
private void AddUpdatePanel(Panel p) { this.messageLabel = new Label(); this.updatePanel = new UpdatePanel(); this.updatePanel.ID = "ScrudUpdatePanel"; this.updatePanel.ChildrenAsTriggers = true; this.updatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional; this.updatePanel.ContentTemplateContainer.Controls.Add(this.topCommandPanel.GetCommandPanel("top")); this.updatePanel.ContentTemplateContainer.Controls.Add(this.messageLabel); this.updatePanel.ContentTemplateContainer.Controls.Add(this.gridPanel); this.updatePanel.ContentTemplateContainer.Controls.Add(this.formPanel); this.updatePanel.ContentTemplateContainer.Controls.Add(this.bottomCommandPanel.GetCommandPanel("bottom")); //Bottom command panel. this.userIdHidden = new HiddenField(); this.userIdHidden.ID = "UserIdHidden"; this.userIdHidden.Value = CurrentSession.GetUserName(); this.officeCodeHidden = new HiddenField(); this.officeCodeHidden.ID = "OfficeCodeHidden"; this.officeCodeHidden.Value = CurrentSession.GetOfficeName(); this.updatePanel.ContentTemplateContainer.Controls.Add(this.userIdHidden); this.updatePanel.ContentTemplateContainer.Controls.Add(this.officeCodeHidden); p.Controls.Add(this.updatePanel); }
private void CheckAccessLevel() { if ((this.AccessLevel.Equals(AccessLevel.AdminOnly) || this.AccessLevel.Equals(AccessLevel.LocalhostAdmin)) && !CurrentSession.IsAdmin()) { Log.Information("Access to {Control} is denied to user.", this, CurrentSession.GetUserName()); this.Page.Server.Transfer("~/Site/AccessIsDenied.aspx"); } bool isLocalHost = PageUtility.IsLocalhost(this.Page); if (this.AccessLevel.Equals(AccessLevel.LocalhostAdmin) && !isLocalHost) { Log.Information("Access to {Control} is denied to user.", this, CurrentSession.GetUserName()); this.Page.Server.Transfer("~/Site/AccessIsDenied.aspx"); } }
public void ChangePasswordButton_Click(object sender, EventArgs e) { string userName = CurrentSession.GetUserName(); string currentPassword = this.passwordInputPassword.Value; string newPassword = this.newPasswordInputPassword.Value; string confirmPassword = this.confirmPasswordInputPassword.Value; if (string.IsNullOrWhiteSpace(currentPassword)) { this.errorMessage.InnerText = Resources.Warnings.PleaseEnterCurrentPassword; return; } if (string.IsNullOrWhiteSpace(newPassword)) { this.errorMessage.InnerText = Resources.Warnings.PleaseEnterNewPassword; return; } if (currentPassword.Equals(newPassword)) { this.errorMessage.InnerText = Resources.Warnings.NewPasswordCannotBeOldPassword; return; } if (!newPassword.Equals(confirmPassword)) { this.errorMessage.InnerText = Resources.Warnings.ConfirmationPasswordDoesNotMatch; return; } try { if (Data.Office.User.ChangePassword(userName, currentPassword, newPassword)) { this.ShowMessage(Resources.Labels.YourPasswordWasChanged, "ui large green header"); } } catch (MixERPException ex) { Log.Warning("Could not change password: {Message}.", ex.Message); this.ShowMessage(ex.Message, "ui large red header"); } }
public override void OnControlLoad(object sender, EventArgs e) { using (TransactionView view = new TransactionView()) { view.DisplayAddButton = true; view.DisplayFlagButton = true; view.DisplayPrintButton = true; view.AddNewPath = "Entry/JournalVoucher.mix"; view.GridViewCssClass = "ui table nowrap"; view.Text = Titles.JournalVoucher; //Default Values view.DateFromFromFrequencyType = FrequencyType.FiscalYearStartDate; view.DateToFrequencyType = FrequencyType.FiscalYearEndDate; view.Book = "Journal"; view.PostedBy = CurrentSession.GetUserName(); view.OfficeName = CurrentSession.GetOfficeName(); view.Status = "Approved"; this.Controls.Add(view); } }
private void CreateBackupNameField(HtmlGenericControl container) { using (HtmlGenericControl field = HtmlControlHelper.GetField()) { using (HtmlGenericControl label = HtmlControlHelper.GetLabel(Titles.EnterBackupName, "BackupNameInputText")) { field.Controls.Add(label); } using (HtmlInputText backupNameInputText = new HtmlInputText()) { this.server.Validate(); backupNameInputText.ID = "BackupNameInputText"; if (this.server.IsValid) { backupNameInputText.Value = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}", this.server.DatabaseName, CurrentSession.GetOfficeId(), CurrentSession.GetUserName(), DateTime.Now.ToFileTime()); } field.Controls.Add(backupNameInputText); } container.Controls.Add(field); } }
protected void Page_Load(object sender, EventArgs e) { this.BranchNameLiteral.Text = CurrentSession.GetOfficeName(); this.SignOutLiteral.Text = Resources.Titles.SignOut; this.UserGreetingLiteral.Text = String.Format(CultureInfo.CurrentCulture, Resources.Labels.UserGreeting, CurrentSession.GetUserName()); this.ChangePasswordLiteral.Text = Resources.Titles.ChangePassword; this.ManageProfileLiteral.Text = Resources.Titles.ManageProfile; this.MixERPDocumentationLiteral.Text = Resources.Titles.MixERPDocumentation; this.NotificationLiteral.Text = Resources.Titles.Notifications; }