-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResetPassword.aspx.cs
More file actions
55 lines (49 loc) · 1.69 KB
/
ResetPassword.aspx.cs
File metadata and controls
55 lines (49 loc) · 1.69 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
namespace teachingPlatform
{
public partial class ResetPassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Reset_Click(object sender, EventArgs e)
{
string newPassword1 = TextBox1.Text;
string newPassword2 = TextBox2.Text;
string email = Session["Email"].ToString();
string connstr = WebConfigurationManager.ConnectionStrings["StudentsDB"].ConnectionString;
SqlConnection con = new SqlConnection(connstr);
if (newPassword1.Equals(newPassword2))
{
try
{
SqlCommand cmd = new SqlCommand("update Registered set Password = @Password where Email = @Email", con);
string encryptedPassword = EncryptionDecryption.Encrypt(newPassword2);
cmd.Parameters.AddWithValue("@Password", encryptedPassword);
cmd.Parameters.AddWithValue("@Email", email);
con.Open();
cmd.ExecuteNonQuery();
}
catch
{
}
finally
{
con.Close();
Label3.Text = "Password successfully reset. Please Login again";
}
}
else
{
Label3.Text = "The two passwords do not match. Please try again.";
}
}
}
}