-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset_handler.ashx.cs
63 lines (51 loc) · 1.85 KB
/
reset_handler.ashx.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
using System;
using System.IO;
using System.Web;
using FooBlog.common;
using Newtonsoft.Json;
namespace FooBlog
{
/// <summary>
/// Summary description for reset_handler
/// </summary>
public class reset_handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string userId = FooSessionHelper.GetUserObjectFromCookie(context).UserId;
string jsonString = new StreamReader(context.Request.InputStream).ReadToEnd();
var resetObj = JsonConvert.DeserializeObject<ResetObject>(jsonString);
string password = resetObj.Password.Trim();
string confirmation = resetObj.Confirmation.Trim();
if (password != confirmation)
{
context.Response.Write("Reset Failed");
}
if (!String.IsNullOrEmpty(password))
{
bool reset = do_reset.UpdatePassword(userId, password);
if (reset)
{
string email = FooEmailHelper.GetEmailForAccount(userId);
var emailObj = new EmailObject
{
Body =
"Your FooBlog password has been reset. If you did not perform this action, please contact a FooBlog administrator using your registered email account",
Subject = "FooBlog Password Reset",
ToAddress = email
};
FooEmailHelper.SendEmail(emailObj);
context.Response.Write("Reset OK");
}
else
{
context.Response.Write("Reset Failed");
}
}
}
public bool IsReusable
{
get { return false; }
}
}
}