-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChangePassword.aspx.cs
162 lines (133 loc) · 5.43 KB
/
ChangePassword.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Xml;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using EPolicy;
using EPolicy.Customer;
using EPolicy.TaskControl;
using Baldrich.DBRequest;
using OPPReport;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;
using EPolicy.Quotes;
using EPolicy.XmlCooker;
using System.Collections.Generic;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using Microsoft.Reporting.WebForms;
using System.IO;
using System.Web.Services;
using System.Configuration;
using System.Xml.Schema;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
namespace EPolicy
{
/// <summary>
/// Summary description for AutoGuardServicesContractReport.
/// </summary>
public partial class ChangePassword : System.Web.UI.Page
{
#region Web Form Designer Generated Code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
//protected void Page_Unload(object sender, EventArgs e)
//{
// Session.Abandon();
//}
private void InitializeComponent()
{
}
#endregion Web Form Designer Generated Code
protected void Page_Load(object sender, EventArgs e)
{
//this.litPopUp.Visible = false;
Session["ChangePassword"] = true;
Control Banner = new Control();
Banner = LoadControl(@"TopBannerNew.ascx");
this.phTopBanner.Controls.Add(Banner);
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString(), "SetWaitCursor();", true);
Login.Login cp = HttpContext.Current.User as Login.Login;
if (cp == null)
{
Response.Redirect("Default.aspx?001");
}
else
{
//if (!cp.IsInRole("CHANGEPASSWORD") && !cp.IsInRole("ADMINISTRATOR"))
//{
// Response.Redirect("Default.aspx?001");
//}
if(Session["Username"] != null)
{
TxtUserName.Text = Session["Username"].ToString();
}
}
}
protected void BtnSave_Click(object sender, System.EventArgs e)
{
Login.Login login = new Login.Login();
try
{
bool IsUserAuthenticate = false;
string encrypt = FormsAuthentication.HashPasswordForStoringInConfigFile(TxtPassword.Text.Trim(), "SHA1");
string newPasswordText = TxtNewPassword.Text;
TxtPassword.Text = "";
if (login.GetAuthenticatedUser(TxtUserName.Text, encrypt))
{
string encryptNewPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(TxtNewPassword.Text.Trim(), "SHA1");
string encryptConfirmPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(TxtConfirmPassword.Text.Trim(), "SHA1");
login.SavePasword(encryptNewPassword, encryptConfirmPassword, encrypt, newPasswordText);
IsUserAuthenticate = login.GetAuthenticatedUser(TxtUserName.Text.Trim(), encryptNewPassword);
}
if (IsUserAuthenticate)
{
TxtUserName.Text = "";
TxtPassword.Text = "";
TxtNewPassword.Text = "";
TxtConfirmPassword.Text = "";
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, login.UserName + "|" + login.UserID.ToString(), DateTime.Now, DateTime.Now.AddHours(10), false, ""); //login.GetRole());
//FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, login.FirstName.Trim() + " " + login.LastName.Trim() + "|" + login.UserName.Trim(), DateTime.Now, DateTime.Now.AddHours(1), false, ""); //login.GetRole());
string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookies = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(authCookies);
Session["ChangePassword"] = null;
Response.Redirect("MainMenu.aspx", true);
}
}
catch (Exception exp)
{
lblRecHeader.Text = exp.Message;
mpeSeleccion.Show();
//this.litPopUp.Text = Utilities.MakeLiteralPopUpString(exp.Message);
//this.litPopUp.Visible = true;
}
}
protected void BtnExit_Click(object sender, System.EventArgs e)
{
FormsAuthentication.SignOut();
HttpCookie authCookies = new HttpCookie(FormsAuthentication.FormsCookieName, null);
Response.Cookies.Add(authCookies);
Session.Add("WrongPass", "Usuario Desconectado Satisfactoria!");
Response.Redirect("Default.aspx?004", true);
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
}
}
}