/// <summary> /// Process submit action /// 1. Get data from layout /// 2. Validate -> show error message? /// 3. Check Login /// </summary> protected void OnVerify() { // 1. Get data from layout // 2. Validate -> show error message? // 3. Check Login -> Redirect to Overview Page or show error message? var model = GetDataFromLayout(); if (!Page.IsValid) { return; } bool isSuccess = CheckLogin(model); if (isSuccess) { // Store session IsManager bool isManager = !UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts); HttpContext.Current.Session[StringConstant.IsAdmin] = isManager; // Redirect to Overview Page Response.Redirect(StringConstant.PageOverviewURL); } else { NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcesKeyLoginMessageFail)); } }
/// <summary> /// Process submit action /// 1. Get data from layout /// 2. Validate -> show error message? /// 3. Update Password -> show success / error message? /// </summary> protected void OnOK() { // 1. Get data from layout // 2. Validate -> show error message? // 3. Update Password -> show success or error message? var model = GetDataFromLayout(); if (Validate(model)) { bool isSuccess = UpdateNewPassword(model); if (isSuccess) { NotificationStatusHelper.SetInformationStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleSuccess), WebPageResourceHelper.GetResourceString( StringConstant.ResourcesKeyResetPasswordMessageSuccess)); //var message = WebPageResourceHelper.GetResourceString(StringConstant.ResourcesKeyResetPasswordMessageSuccess); //Response.Write($"<script>alert('{message}');</script>"); //this.ShowMessageSuccess(MessageSuccessResetPasswordSuccess); } else { NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString( StringConstant.ResourcesKeyResetPasswordMessageUnsuccess)); // ShowMessageError(MessageErrorResetPasswordUnsuccess); } } else { // Validate fail! } }
/// <summary> /// Event delegate call On OK /// </summary> /// <param name="sender">A object sender</param> /// <param name="e">A System.EventArgs store data</param> protected void Button_OK_Click(object sender, EventArgs e) { try { OnOK(); } catch (Exception ex) { // Write log to SharePoint ULSLogging.LogError(ex); NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralMessageError)); } }
/// <summary> /// Page Load /// </summary> /// <param name="sender">A objects sender </param> /// <param name="e">A System.EventArgs that contains the event data.</param> protected void Page_Load(object sender, EventArgs e) { try { // Check postback if (!Page.IsPostBack) { FirstLoad(); } } catch (Exception ex) { // Write log to SharePoint ULSLogging.LogError(ex); NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralMessageError)); } }
/// <summary> /// Process submit action /// 1. Get data from layout /// 2. Validate -> show error message? /// 3. Update Password -> show success / error message? /// </summary> protected void OnOK() { // 1. Get data from layout // 2. Validate -> show error message? // 3. Update Password -> show success / error message? var model = GetDataFromLayout(); if (!Page.IsValid) { return; } bool currentPasswordValid = ValidateCurrentPassword(model); if (!currentPasswordValid) { NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString( StringConstant.ResourcesKeyChangePasswordCurrentPasswordIsInValid)); } else { bool isSuccess = UpdateNewPassword(model); if (!isSuccess) { NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleSuccess), WebPageResourceHelper.GetResourceString( StringConstant.ResourcesKeyChangePasswordMessageUnsuccess)); } else { NotificationStatusHelper.SetInformationStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleSuccess), WebPageResourceHelper.GetResourceString( StringConstant.ResourcesKeyChangePasswordMessageSuccess)); //Log out //Response.Redirect(StringConstant.PageLogoutURL); SPUtility.Redirect(StringConstant.PageLogoutURL, SPRedirectFlags.DoNotEndResponse | SPRedirectFlags.Trusted, HttpContext.Current); } } }
/// <summary> /// Process submit action /// 1. Get data from layout /// 2. Validate -> show error message? /// 3. Check Login /// </summary> protected void OnVerify() { // 1. Get data from layout // 2. Validate -> show error message? // 3. Check Login -> Redirect to Overview Page or show error message? var model = GetDataFromLayout(); if (!Page.IsValid) { return; } bool isSuccess = CheckLogin(model); if (isSuccess) { var isCurrentUserInCommonGroup = false; if (Page.Session[SessionKey.IsCurrentUserInCommonGroup] != null) { bool.TryParse(Page.Session[SessionKey.IsCurrentUserInCommonGroup].ToString(), out isCurrentUserInCommonGroup); } else { isCurrentUserInCommonGroup = UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts); Page.Session[SessionKey.IsCurrentUserInCommonGroup] = isCurrentUserInCommonGroup; } // Store session IsManager //bool isManager = !UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts); bool isManager = !isCurrentUserInCommonGroup; HttpContext.Current.Session[StringConstant.IsAdmin] = isManager; // Redirect to Overview Page //Response.Redirect(StringConstant.PageOverviewURL); SPUtility.Redirect(StringConstant.PageOverviewURL, SPRedirectFlags.DoNotEndResponse | SPRedirectFlags.Trusted, HttpContext.Current); } else { NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcesKeyLoginMessageFail)); } }