Commit c30c6bdd690f09fb9b215a88f9b6b0f745f6770a

Authored by Utkarsh Singh
1 parent 88b3ee43

Committed code. Refs: #15245, 15885

400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs
... ... @@ -45,15 +45,15 @@ namespace AIAHTML5.API.Controllers
45 45  
46 46 logger.Debug("1. inside if in ForgotUserController userDetails= " + userDetails);
47 47  
48   - if (Convert.ToBoolean(userInfo["isPassword"]))
  48 + if (Convert.ToBoolean(userInfo["havePassword"]))
49 49 {
50   - logger.Debug("2. isPassword= " + Convert.ToBoolean(userInfo["isPassword"]));
  50 + logger.Debug("2. havePassword= " + Convert.ToBoolean(userInfo["havePassword"]));
51 51  
52 52 isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, true);
53 53 }
54 54 else
55 55 {
56   - logger.Debug("3. isPassword= " + Convert.ToBoolean(userInfo["isPassword"]));
  56 + logger.Debug("3. havePassword= " + Convert.ToBoolean(userInfo["havePassword"]));
57 57  
58 58 isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, false);
59 59 }
... ...
400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs
... ... @@ -18,10 +18,10 @@ namespace AIAHTML5.API.Models
18 18 {
19 19 public class UserUtility
20 20 {
21   - public static bool SendEmail(dynamic UserDetails, bool isPassword)
  21 + public static bool SendEmail(dynamic UserDetails, bool havePassword)
22 22 {
23 23 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
24   - logger.Debug("inside SendEmail in for isPassword =" + isPassword);
  24 + logger.Debug("inside SendEmail in for isPassword =" + havePassword);
25 25  
26 26 try
27 27 {
... ... @@ -37,24 +37,20 @@ namespace AIAHTML5.API.Models
37 37 string fName = string.Empty;
38 38 string lName = string.Empty;
39 39 string site_url = Convert.ToString(ConfigurationManager.AppSettings["Site_URL"]);
40   - bool isAdminRequest = false;
41 40  
42   - foreach (KeyValuePair<string, object> kvp in UserDetails)
  41 + foreach (KeyValuePair<string, object> userObj in UserDetails)
43 42 {
44   - if (kvp.Key == "loginId")
45   - userId = kvp.Value.ToString();
  43 + if (userObj.Key == "loginId")
  44 + userId = userObj.Value.ToString();
46 45  
47   - if (kvp.Key == "emailId")
48   - userMail = kvp.Value.ToString();
  46 + if (userObj.Key == "emailId")
  47 + userMail = userObj.Value.ToString();
49 48  
50   - if (kvp.Key == "firstName")
51   - fName = kvp.Value.ToString();
  49 + if (userObj.Key == "firstName")
  50 + fName = userObj.Value.ToString();
52 51  
53   - if (kvp.Key == "lastName")
54   - lName = kvp.Value.ToString();
55   -
56   - if (kvp.Key == "isAdmin")
57   - isAdminRequest = Convert.ToBoolean(kvp.Value);
  52 + if (userObj.Key == "lastName")
  53 + lName = userObj.Value.ToString();
58 54 }
59 55  
60 56 string fullName = fName + " " + lName;
... ... @@ -64,21 +60,13 @@ namespace AIAHTML5.API.Models
64 60 string templatePath = string.Empty;
65 61 string resetPasswordLink = string.Empty;
66 62  
67   - if (isAdminRequest)
  63 + if (havePassword)
68 64 {
69   - templatePath = "~/Templates/admin-Request.html";
  65 + templatePath = "~/Templates/forgot-Password.html";
  66 + resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail);
70 67 }
71 68 else
72   - {
73   - if (isPassword)
74   - {
75   - templatePath = "~/Templates/forgot-Password.html";
76   - resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail);
77   - }
78   - else
79   - templatePath = "~/Templates/forgot-UserId.html";
80   - }
81   -
  69 + templatePath = "~/Templates/forgot-UserId.html";
82 70  
83 71 logger.Debug("inside SendEmail for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordLink);
84 72 string mailBody = UserUtility.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, resetPasswordLink);
... ... @@ -105,15 +93,10 @@ namespace AIAHTML5.API.Models
105 93 }
106 94  
107 95 string mailSubject = string.Empty;
108   - if (isAdminRequest)
109   - mailSubject = "'Admin' request for: ";
  96 + if (!havePassword)
  97 + mailSubject = "UserID recovery mail for: ";
110 98 else
111   - {
112   - if (!isPassword)
113   - mailSubject = "UserID recovery mail for: ";
114   - else
115   - mailSubject = "Password recovery mail for: ";
116   - }
  99 + mailSubject = "Password recovery mail for: ";
117 100  
118 101  
119 102 emailUtility.sHostName = Convert.ToString(ConfigurationManager.AppSettings["HostAddress"]);
... ... @@ -121,7 +104,6 @@ namespace AIAHTML5.API.Models
121 104 emailUtility.bIsBodyHtml = true;
122 105 emailUtility.bEnableSsl = false;
123 106 emailUtility.sSubject = mailSubject + userMail;
124   - //sEmailUtility.sBodyText = sEmailText;
125 107 emailUtility.iPort = 25;
126 108 emailUtility.sToAddresses = lstToAddress;
127 109 emailUtility.sBccAddresses = lstBccAddress;
... ... @@ -139,7 +121,7 @@ namespace AIAHTML5.API.Models
139 121 protected static string GetMailBodyTextFromTemplate(string templatePath, string userId, string userMail, string fullName, string resetPasswordUrl)
140 122 {
141 123 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
142   - logger.Debug("inside GetMailBodyTextFromTemplate for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordUrl);
  124 + logger.Debug("Inside GetMailBodyTextFromTemplate for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordUrl);
143 125  
144 126 string fileToRead = string.Empty;
145 127 string emailBody = string.Empty;
... ... @@ -176,14 +158,11 @@ namespace AIAHTML5.API.Models
176 158  
177 159 try
178 160 {
179   - //List<LinkedResource> lstLinkedResource = new List<LinkedResource>();
180 161 EmailUtility emailUtility = new EmailUtility();
181 162 List<string> lstToAddress = new List<string>();
182 163 List<string> lstBccAddress = new List<string>();
183 164  
184   - string userId = string.Empty;
185 165 string userMail = string.Empty;
186   - string userName = string.Empty;
187 166 string fullName = string.Empty;
188 167 string emailMessage = string.Empty;
189 168  
... ... @@ -200,37 +179,14 @@ namespace AIAHTML5.API.Models
200 179 userMail = userInfo["emailId"].ToString();
201 180 emailMessage = userInfo["userMessage"].ToString();
202 181  
203   - //string logoPath = HttpContext.Current.Server.MapPath("~/content/images/logo.png");
204   -
205   - //string templatePath = string.Empty;
206   - //string resetPasswordLink = string.Empty;
207   -
208 182 lstToAddress.Add(userMail);
209 183  
210 184 emailMessage = emailMessage.Replace("\n", "<br/>");
211 185  
212 186 emailMessage += "<br/><br/>";
213 187  
214   - //logger.Debug("emailText= " + emailText);
215   - //// for embedding images in email
216   - //if (emailText.Contains("<img"))
217   - //{
218   - // LinkedResource linkedLogo = new LinkedResource(logoPath, MediaTypeNames.Image.Jpeg);
219   - // linkedLogo.ContentId = "AIA_Logo_Image";
220   - // linkedLogo.TransferEncoding = TransferEncoding.Base64;
221   - // emailText = emailText.Replace("{logoPath}", "cid:" + linkedLogo.ContentId);
222   - // lstLinkedResource.Add(linkedLogo);
223   - //}
224   -
225   - //emailUtility.sAlternateView = AlternateView.CreateAlternateViewFromString(emailText, null, "text/html");
226   - //foreach (var sItem in lstLinkedResource)
227   - //{
228   - // emailUtility.sAlternateView.LinkedResources.Add(sItem);
229   - //}
230   -
231 188 string mailSubject = "Admin Support request initiated for:";
232 189  
233   -
234 190 emailUtility.sHostName = Convert.ToString(ConfigurationManager.AppSettings["HostAddress"]);
235 191 emailUtility.sFromAddress = Convert.ToString(ConfigurationManager.AppSettings["SenderEmailAddress"]);
236 192 emailUtility.bIsBodyHtml = true;
... ... @@ -246,7 +202,7 @@ namespace AIAHTML5.API.Models
246 202 }
247 203 catch (Exception ex)
248 204 {
249   - string message = "Exception: " + ex.Message;
  205 + logger.Fatal("exception in GetMailBodyTextFromTemplate. msg= " + ex.Message + ", stacktrace= " + ex.StackTrace);
250 206 return false;
251 207 }
252 208 }
... ...
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config
... ... @@ -30,7 +30,7 @@
30 30 </root>
31 31 </log4net>
32 32  
33   - <appSettings>
  33 + <!--<appSettings>
34 34 <add key="SenderEmailAddress" value="support@interactiveanatomy.com" />
35 35 <add key="ErrorNotificationEmailAddress" value="support@interactiveanatomy.com" />
36 36 <add key="SenderPassword" value="" />
... ... @@ -39,8 +39,20 @@
39 39 <add key="EnableSSL" value="false" />
40 40 <add key="Site_Url" value ="//52.2.38.120"/>
41 41 <add key ="HostAddress" value="10.100.12.13" />
42   - <add key="isUserAuthenticated" value="True"/>
  42 + <add key="isUserAuthenticated" value="false"/>
43 43 <add key="AdminSupport" value=""/>
  44 + </appSettings>-->
  45 + <appSettings>
  46 + <add key="SenderEmailAddress" value="utkarsh.singh@ebix.com" />
  47 + <add key="ErrorNotificationEmailAddress" value="support@interactiveanatomy.com" />
  48 + <add key="SenderPassword" value="utkarsh@3bix" />
  49 + <add key="SMTPAddress" value="smtp.emailsrvr.com" />
  50 + <add key="SMTPPort" value="587" />
  51 + <add key="EnableSSL" value="false" />
  52 + <add key="Site_Url" value ="//192.168.86.34:82/AIA"/>
  53 + <add key ="HostAddress" value="10.100.12.13" />
  54 + <add key="isUserAuthenticated" value="false"/>
  55 + <add key="AdminSupport" value="utkarsh.singh@ebix.com"/>
44 56 </appSettings>
45 57 <system.web>
46 58 <compilation debug="true" targetFramework="4.5" />
... ...
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb
No preview for this file type
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -75,7 +75,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
75 75 username: null,
76 76 password: null,
77 77 emailId: null,
78   - isPassword: null,
  78 + havePassword: null,
79 79 newPassword: null,
80 80 confirmPassword: null,
81 81 userMessage: null
... ... @@ -202,9 +202,9 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
202 202 if ((userInfo.emailId != null) && (userInfo.emailId != '')) {
203 203 if (validateEmail(userInfo.emailId)) {
204 204 if (isMailForPassword == true)
205   - userInfo.isPassword = true;
  205 + userInfo.havePassword = true;
206 206 else
207   - userInfo.isPassword = false;
  207 + userInfo.havePassword = false;
208 208  
209 209 AuthenticationService.SendMailToUser(userInfo)
210 210 .then(function (result) {
... ... @@ -3327,7 +3327,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3327 3327 }
3328 3328 },
3329 3329 function (error) {
3330   - console.log(' Error in intimating admin support = ' + error.statusText);
  3330 + console.log(' Error in sending mail to admin support = ' + error.statusText);
3331 3331 $rootScope.errorMassage = AdminConstants.ERROR_IN_SENDING_MAIL;
3332 3332 $("#messageModal").modal('show');
3333 3333 });
... ...
400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js
... ... @@ -18,7 +18,7 @@
18 18 return deferred.promise;
19 19 },
20 20  
21   - SendMailToUser: function (userInfo, isPassword) {
  21 + SendMailToUser: function (userInfo, havePassword) {
22 22 var deferred = $q.defer();
23 23  
24 24 $http.post('/API/api/ForgotUser', userInfo, { //JSON.stringify(userEmail)
... ...