Commit 7de537480ce2dddc90bef24deab105bdc18a54a4
1 parent
48bae682
Commited code Branch ResetPass_COmplete
Showing
4 changed files
with
66 additions
and
96 deletions
400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs
... | ... | @@ -39,14 +39,14 @@ namespace AIAHTML5.API.Controllers |
39 | 39 | dynamic userData = AIAHTML5.API.Models.Users.GetUserByEmail(userInfo); |
40 | 40 | if (Convert.ToString(userData) != AIAConstants.USER_NOT_FOUND && Convert.ToString(userData) != AIAConstants.ERROR_IN_FECTHING_DETAILS) |
41 | 41 | { |
42 | - bool res = false; | |
42 | + bool isMailSent = false; | |
43 | 43 | string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(userData); |
44 | 44 | if (Convert.ToBoolean(userInfo["isPassword"])) |
45 | - res = AIAHTML5.API.Models.ResetUser.SendEmail(userData, true); | |
45 | + isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, true); | |
46 | 46 | else |
47 | - res = AIAHTML5.API.Models.ResetUser.SendEmail(userData, false); | |
47 | + isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, false); | |
48 | 48 | |
49 | - if (res) | |
49 | + if (isMailSent) | |
50 | 50 | return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userDetails) }; |
51 | 51 | else |
52 | 52 | return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(userData) }; | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs
... | ... | @@ -23,90 +23,88 @@ namespace AIAHTML5.API.Models |
23 | 23 | try |
24 | 24 | { |
25 | 25 | List<LinkedResource> lstLinkedResource = new List<LinkedResource>(); |
26 | - EmailUtility sEmailUtility = new EmailUtility(); | |
26 | + EmailUtility emailUtility = new EmailUtility(); | |
27 | 27 | List<string> lstToAddress = new List<string>(); |
28 | 28 | List<string> lstBccAddress = new List<string>(); |
29 | 29 | |
30 | - string sEmailText = string.Empty; | |
31 | - string _userId = string.Empty; | |
32 | - string _password = string.Empty; | |
33 | - string _userMail = string.Empty; | |
34 | - string _userName = string.Empty; | |
35 | - string _fName = string.Empty; | |
36 | - string _lName = string.Empty; | |
37 | - string _site_url = Convert.ToString(ConfigurationManager.AppSettings["Site_URL"]); | |
30 | + string emailText = string.Empty; | |
31 | + string userId = string.Empty; | |
32 | + string userMail = string.Empty; | |
33 | + string userName = string.Empty; | |
34 | + string fName = string.Empty; | |
35 | + string lName = string.Empty; | |
36 | + string site_url = Convert.ToString(ConfigurationManager.AppSettings["Site_URL"]); | |
38 | 37 | |
39 | 38 | foreach (KeyValuePair<string, object> kvp in UserDetails) |
40 | 39 | { |
41 | 40 | if (kvp.Key == "loginId") |
42 | - _userId = kvp.Value.ToString(); | |
43 | - | |
44 | - if (kvp.Key == "password") | |
45 | - _password = kvp.Value.ToString(); | |
41 | + userId = kvp.Value.ToString(); | |
46 | 42 | |
47 | 43 | if (kvp.Key == "emailId") |
48 | - _userMail = kvp.Value.ToString(); | |
44 | + userMail = kvp.Value.ToString(); | |
49 | 45 | |
50 | 46 | if (kvp.Key == "firstName") |
51 | - _fName = kvp.Value.ToString(); | |
47 | + fName = kvp.Value.ToString(); | |
52 | 48 | |
53 | 49 | if (kvp.Key == "lastName") |
54 | - _lName = kvp.Value.ToString(); | |
50 | + lName = kvp.Value.ToString(); | |
55 | 51 | } |
56 | 52 | |
57 | - string _fullName = _fName + " " + _lName; | |
53 | + string fullName = fName + " " + lName; | |
58 | 54 | |
59 | - string _logoPath = HttpContext.Current.Server.MapPath("~/content/images/logo.png"); | |
55 | + string logoPath = HttpContext.Current.Server.MapPath("~/content/images/logo.png"); | |
60 | 56 | |
61 | - string _templatePath = string.Empty; | |
57 | + string templatePath = string.Empty; | |
58 | + string resetPasswordLink = string.Empty; | |
62 | 59 | |
63 | - if (!isPassword) | |
64 | - _templatePath = "~/Templates/forgot-UserId.html"; | |
60 | + if (isPassword) | |
61 | + { | |
62 | + templatePath = "~/Templates/forgot-Password.html"; | |
63 | + resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail); | |
64 | + } | |
65 | 65 | else |
66 | - _templatePath = "~/Templates/forgot-Password.html"; | |
67 | - | |
68 | - string _resetPassLink = _site_url + "?em:" + HttpUtility.UrlEncode(_userMail); | |
66 | + templatePath = "~/Templates/forgot-UserId.html"; | |
69 | 67 | |
70 | - string mailBody = ResetUser.ReadMailBodyTextFromFile(_templatePath, _userId, _password, _userMail, _fullName, _resetPassLink); | |
68 | + string mailBody = ResetUser.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, resetPasswordLink); | |
71 | 69 | |
72 | - lstToAddress.Add(_userMail); | |
70 | + lstToAddress.Add(userMail); | |
73 | 71 | |
74 | - sEmailText = mailBody; | |
72 | + emailText = mailBody; | |
75 | 73 | |
76 | 74 | |
77 | 75 | // for embedding images in email |
78 | - if (sEmailText.Contains("<img")) | |
76 | + if (emailText.Contains("<img")) | |
79 | 77 | { |
80 | - LinkedResource inline = new LinkedResource(_logoPath, MediaTypeNames.Image.Jpeg); | |
81 | - inline.ContentId = "AIA_Logo_Image"; | |
82 | - inline.TransferEncoding = TransferEncoding.Base64; | |
83 | - sEmailText = sEmailText.Replace("{logoPath}", "cid:" + inline.ContentId); | |
84 | - lstLinkedResource.Add(inline); | |
78 | + LinkedResource linkedLogo = new LinkedResource(logoPath, MediaTypeNames.Image.Jpeg); | |
79 | + linkedLogo.ContentId = "AIA_Logo_Image"; | |
80 | + linkedLogo.TransferEncoding = TransferEncoding.Base64; | |
81 | + emailText = emailText.Replace("{logoPath}", "cid:" + linkedLogo.ContentId); | |
82 | + lstLinkedResource.Add(linkedLogo); | |
85 | 83 | } |
86 | 84 | |
87 | - sEmailUtility.sAlternateView = AlternateView.CreateAlternateViewFromString(sEmailText, null, "text/html"); | |
85 | + emailUtility.sAlternateView = AlternateView.CreateAlternateViewFromString(emailText, null, "text/html"); | |
88 | 86 | foreach (var sItem in lstLinkedResource) |
89 | 87 | { |
90 | - sEmailUtility.sAlternateView.LinkedResources.Add(sItem); | |
88 | + emailUtility.sAlternateView.LinkedResources.Add(sItem); | |
91 | 89 | } |
92 | 90 | |
93 | - string _mailSubject = string.Empty; | |
91 | + string mailSubject = string.Empty; | |
94 | 92 | if(!isPassword) |
95 | - _mailSubject = "UserID recovery mail for: "; | |
93 | + mailSubject = "UserID recovery mail for: "; | |
96 | 94 | else |
97 | - _mailSubject = "Password recovery mail for: "; | |
95 | + mailSubject = "Password recovery mail for: "; | |
98 | 96 | |
99 | - sEmailUtility.sHostName = "10.100.12.13"; | |
100 | - sEmailUtility.sFromAddress = "utkarsh.singh@ebix.com"; | |
101 | - sEmailUtility.bIsBodyHtml = true; | |
102 | - sEmailUtility.bEnableSsl = false; | |
103 | - sEmailUtility.sSubject = _mailSubject + _userMail; | |
97 | + emailUtility.sHostName = "10.100.12.13"; | |
98 | + emailUtility.sFromAddress = Convert.ToString(ConfigurationManager.AppSettings["SenderEmailAddress"]); | |
99 | + emailUtility.bIsBodyHtml = true; | |
100 | + emailUtility.bEnableSsl = false; | |
101 | + emailUtility.sSubject = mailSubject + userMail; | |
104 | 102 | //sEmailUtility.sBodyText = sEmailText; |
105 | - sEmailUtility.iPort = 25; | |
106 | - sEmailUtility.sToAddresses = lstToAddress; | |
107 | - sEmailUtility.sBccAddresses = lstBccAddress; | |
103 | + emailUtility.iPort = 25; | |
104 | + emailUtility.sToAddresses = lstToAddress; | |
105 | + emailUtility.sBccAddresses = lstBccAddress; | |
108 | 106 | |
109 | - sEmailUtility.SendSmtpEmail(); | |
107 | + emailUtility.SendSmtpEmail(); | |
110 | 108 | return true; |
111 | 109 | } |
112 | 110 | catch (Exception ex) |
... | ... | @@ -116,29 +114,33 @@ namespace AIAHTML5.API.Models |
116 | 114 | } |
117 | 115 | } |
118 | 116 | |
119 | - protected static string ReadMailBodyTextFromFile(string templatePath, string userId, string password, string userMail, string fullName, string resetPasswordUrl) | |
117 | + protected static string GetMailBodyTextFromTemplate(string templatePath, string userId, string userMail, string fullName, string resetPasswordUrl) | |
120 | 118 | { |
121 | 119 | string fileToRead = string.Empty; |
122 | - string sBody = string.Empty; | |
120 | + string emailBody = string.Empty; | |
123 | 121 | try |
124 | 122 | { |
125 | 123 | fileToRead = HttpContext.Current.Server.MapPath(templatePath); |
126 | 124 | |
127 | 125 | using (StreamReader reader = new StreamReader(fileToRead)) |
128 | 126 | { |
129 | - sBody = reader.ReadToEnd(); | |
127 | + emailBody = reader.ReadToEnd(); | |
130 | 128 | } |
131 | 129 | |
132 | - sBody = sBody.Replace("{loginId}", userId); | |
133 | - sBody = sBody.Replace("{emailId}", userMail); | |
134 | - sBody = sBody.Replace("{userFullName}", fullName); | |
135 | - sBody = sBody.Replace("{resetPasswordLink}", resetPasswordUrl); | |
130 | + if(!string.IsNullOrEmpty(userId)) | |
131 | + emailBody = emailBody.Replace("{loginId}", userId); | |
132 | + if (!string.IsNullOrEmpty(userMail)) | |
133 | + emailBody = emailBody.Replace("{emailId}", userMail); | |
134 | + if(!string.IsNullOrEmpty(fullName)) | |
135 | + emailBody = emailBody.Replace("{userFullName}", fullName); | |
136 | + if(!string.IsNullOrEmpty(resetPasswordUrl)) | |
137 | + emailBody = emailBody.Replace("{resetPasswordLink}", resetPasswordUrl); | |
136 | 138 | } |
137 | 139 | catch (Exception e) |
138 | 140 | { |
139 | - sBody = "Exception: " + e.Message; | |
141 | + emailBody = "Exception: " + e.Message; | |
140 | 142 | } |
141 | - return sBody; | |
143 | + return emailBody; | |
142 | 144 | } |
143 | 145 | } |
144 | 146 | } |
145 | 147 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs
... | ... | @@ -36,23 +36,7 @@ namespace AIAHTML5.API.Utility |
36 | 36 | System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(mm.From.ToString(), ConfigurationManager.AppSettings["SenderPassword"]); |
37 | 37 | smtp.Credentials = NetworkCred; |
38 | 38 | smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]); |
39 | - /*string ccAddress = ConfigurationManager.AppSettings["NotifyCopyAddress"]; | |
40 | - string[] emailArr = ccAddress.Split(','); | |
41 | - if (mm.From.ToString().Equals("pfizerhelp@ebix.com")) | |
42 | - { | |
43 | - ccAddress = emailArr[0]; | |
44 | - if (!ccAddress.Equals("")) | |
45 | - { | |
46 | - mm.Bcc.Add(ccAddress); | |
47 | - } | |
48 | - } | |
49 | - else | |
50 | - { | |
51 | - if (!ccAddress.Equals("")) | |
52 | - { | |
53 | - mm.Bcc.Add(ccAddress); | |
54 | - } | |
55 | - }*/ | |
39 | + | |
56 | 40 | smtp.Send(mm); |
57 | 41 | } |
58 | 42 | |
... | ... | @@ -106,14 +90,11 @@ namespace AIAHTML5.API.Utility |
106 | 90 | SmtpServer.Credentials = new System.Net.NetworkCredential(sUserName, sPassword); |
107 | 91 | SmtpServer.EnableSsl = bEnableSsl; |
108 | 92 | |
109 | - // SmtpServer.Send(sMail); | |
110 | 93 | using (MailMessage mm = new MailMessage(sFromAddress, sMail.To.ToString())) |
111 | - //using (MailMessage mm = new MailMessage()) | |
112 | 94 | { |
113 | 95 | mm.Subject = sSubject; |
114 | 96 | mm.IsBodyHtml = bIsBodyHtml; |
115 | - // mm.To.Add(sMail.To.ToString()); | |
116 | - //mm.From = new MailAddress(sFromAddress, "AdamOnDemand"); | |
97 | + | |
117 | 98 | if (sAlternateView != null) |
118 | 99 | { |
119 | 100 | mm.AlternateViews.Add(sAlternateView); |
... | ... | @@ -122,20 +103,7 @@ namespace AIAHTML5.API.Utility |
122 | 103 | { |
123 | 104 | mm.Body = sBodyText; |
124 | 105 | } |
125 | - // mm.Body = sAlternateView; | |
126 | - // string bccAddress = (!string.IsNullOrEmpty(sBccAddresses) ? lstBccAddress : ConfigurationManager.AppSettings["AccountsEmailAddress"]); | |
127 | - /* if (sBccAddresses != null) | |
128 | - { | |
129 | - foreach (var sItem in sBccAddresses) | |
130 | - { | |
131 | - mm.Bcc.Add(sItem); | |
132 | - } | |
133 | - }*/ | |
134 | - //else | |
135 | - //{ | |
136 | - // string bccAddress = ConfigurationManager.AppSettings["AccountsEmailAddress"]; | |
137 | - // mm.Bcc.Add(bccAddress); | |
138 | - //} | |
106 | + | |
139 | 107 | mm.IsBodyHtml = true; |
140 | 108 | SendMail(mm); |
141 | 109 | } | ... | ... |
400-SOURCECODE/AIAHTML5.Web/index.html
... | ... | @@ -1124,7 +1124,7 @@ |
1124 | 1124 | <td> |
1125 | 1125 | <input class="form-control" name="confirmPassword" value="*****" type="password" style="padding:3px 5px; height:25px; width:98%;" ng-model="userInfo.confirmPassword" required> |
1126 | 1126 | <span style="color: maroon; font-weight: bold; " ng-show="resetPwdForm.confirmPassword.$touched && resetPwdForm.confirmPassword.$invalid">Confirm password is required.</span> |
1127 | - <!--<span style="color: maroon; font-weight: bold; " ng-if="message">{{message}}</span>--> | |
1127 | + <span style="color: maroon; font-weight: bold; " ng-if="errorMesaage">{{errorMesaage}}</span> | |
1128 | 1128 | </td> |
1129 | 1129 | </tr> |
1130 | 1130 | <tr> | ... | ... |