From c30c6bdd690f09fb9b215a88f9b6b0f745f6770a Mon Sep 17 00:00:00 2001 From: Utkarsh Singh Date: Fri, 17 Mar 2017 15:00:08 +0530 Subject: [PATCH] Committed code. Refs: #15245, 15885 --- 400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs | 6 +++--- 400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs | 84 ++++++++++++++++++++---------------------------------------------------------------- 400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config | 16 ++++++++++++++-- 400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb | Bin 46592 -> 0 bytes 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 8 ++++---- 400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js | 2 +- 6 files changed, 42 insertions(+), 74 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs index f364ee9..2d705a2 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs @@ -45,15 +45,15 @@ namespace AIAHTML5.API.Controllers logger.Debug("1. inside if in ForgotUserController userDetails= " + userDetails); - if (Convert.ToBoolean(userInfo["isPassword"])) + if (Convert.ToBoolean(userInfo["havePassword"])) { - logger.Debug("2. isPassword= " + Convert.ToBoolean(userInfo["isPassword"])); + logger.Debug("2. havePassword= " + Convert.ToBoolean(userInfo["havePassword"])); isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, true); } else { - logger.Debug("3. isPassword= " + Convert.ToBoolean(userInfo["isPassword"])); + logger.Debug("3. havePassword= " + Convert.ToBoolean(userInfo["havePassword"])); isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, false); } diff --git a/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs index 11cbcc6..f42e1ab 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs @@ -18,10 +18,10 @@ namespace AIAHTML5.API.Models { public class UserUtility { - public static bool SendEmail(dynamic UserDetails, bool isPassword) + public static bool SendEmail(dynamic UserDetails, bool havePassword) { ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); - logger.Debug("inside SendEmail in for isPassword =" + isPassword); + logger.Debug("inside SendEmail in for isPassword =" + havePassword); try { @@ -37,24 +37,20 @@ namespace AIAHTML5.API.Models string fName = string.Empty; string lName = string.Empty; string site_url = Convert.ToString(ConfigurationManager.AppSettings["Site_URL"]); - bool isAdminRequest = false; - foreach (KeyValuePair kvp in UserDetails) + foreach (KeyValuePair userObj in UserDetails) { - if (kvp.Key == "loginId") - userId = kvp.Value.ToString(); + if (userObj.Key == "loginId") + userId = userObj.Value.ToString(); - if (kvp.Key == "emailId") - userMail = kvp.Value.ToString(); + if (userObj.Key == "emailId") + userMail = userObj.Value.ToString(); - if (kvp.Key == "firstName") - fName = kvp.Value.ToString(); + if (userObj.Key == "firstName") + fName = userObj.Value.ToString(); - if (kvp.Key == "lastName") - lName = kvp.Value.ToString(); - - if (kvp.Key == "isAdmin") - isAdminRequest = Convert.ToBoolean(kvp.Value); + if (userObj.Key == "lastName") + lName = userObj.Value.ToString(); } string fullName = fName + " " + lName; @@ -64,21 +60,13 @@ namespace AIAHTML5.API.Models string templatePath = string.Empty; string resetPasswordLink = string.Empty; - if (isAdminRequest) + if (havePassword) { - templatePath = "~/Templates/admin-Request.html"; + templatePath = "~/Templates/forgot-Password.html"; + resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail); } else - { - if (isPassword) - { - templatePath = "~/Templates/forgot-Password.html"; - resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail); - } - else - templatePath = "~/Templates/forgot-UserId.html"; - } - + templatePath = "~/Templates/forgot-UserId.html"; logger.Debug("inside SendEmail for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordLink); string mailBody = UserUtility.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, resetPasswordLink); @@ -105,15 +93,10 @@ namespace AIAHTML5.API.Models } string mailSubject = string.Empty; - if (isAdminRequest) - mailSubject = "'Admin' request for: "; + if (!havePassword) + mailSubject = "UserID recovery mail for: "; else - { - if (!isPassword) - mailSubject = "UserID recovery mail for: "; - else - mailSubject = "Password recovery mail for: "; - } + mailSubject = "Password recovery mail for: "; emailUtility.sHostName = Convert.ToString(ConfigurationManager.AppSettings["HostAddress"]); @@ -121,7 +104,6 @@ namespace AIAHTML5.API.Models emailUtility.bIsBodyHtml = true; emailUtility.bEnableSsl = false; emailUtility.sSubject = mailSubject + userMail; - //sEmailUtility.sBodyText = sEmailText; emailUtility.iPort = 25; emailUtility.sToAddresses = lstToAddress; emailUtility.sBccAddresses = lstBccAddress; @@ -139,7 +121,7 @@ namespace AIAHTML5.API.Models protected static string GetMailBodyTextFromTemplate(string templatePath, string userId, string userMail, string fullName, string resetPasswordUrl) { ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); - logger.Debug("inside GetMailBodyTextFromTemplate for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordUrl); + logger.Debug("Inside GetMailBodyTextFromTemplate for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordUrl); string fileToRead = string.Empty; string emailBody = string.Empty; @@ -176,14 +158,11 @@ namespace AIAHTML5.API.Models try { - //List lstLinkedResource = new List(); EmailUtility emailUtility = new EmailUtility(); List lstToAddress = new List(); List lstBccAddress = new List(); - string userId = string.Empty; string userMail = string.Empty; - string userName = string.Empty; string fullName = string.Empty; string emailMessage = string.Empty; @@ -200,37 +179,14 @@ namespace AIAHTML5.API.Models userMail = userInfo["emailId"].ToString(); emailMessage = userInfo["userMessage"].ToString(); - //string logoPath = HttpContext.Current.Server.MapPath("~/content/images/logo.png"); - - //string templatePath = string.Empty; - //string resetPasswordLink = string.Empty; - lstToAddress.Add(userMail); emailMessage = emailMessage.Replace("\n", "
"); emailMessage += "

"; - //logger.Debug("emailText= " + emailText); - //// for embedding images in email - //if (emailText.Contains(" @@ -39,8 +39,20 @@ - + + --> + + + + + + + + + + + diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb index 564e5c5..a978734 100644 Binary files a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb and b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb differ diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 0504955..dc5d273 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -75,7 +75,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic username: null, password: null, emailId: null, - isPassword: null, + havePassword: null, newPassword: null, confirmPassword: null, userMessage: null @@ -202,9 +202,9 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic if ((userInfo.emailId != null) && (userInfo.emailId != '')) { if (validateEmail(userInfo.emailId)) { if (isMailForPassword == true) - userInfo.isPassword = true; + userInfo.havePassword = true; else - userInfo.isPassword = false; + userInfo.havePassword = false; AuthenticationService.SendMailToUser(userInfo) .then(function (result) { @@ -3327,7 +3327,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } }, function (error) { - console.log(' Error in intimating admin support = ' + error.statusText); + console.log(' Error in sending mail to admin support = ' + error.statusText); $rootScope.errorMassage = AdminConstants.ERROR_IN_SENDING_MAIL; $("#messageModal").modal('show'); }); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js index 76d14c8..05e1c3b 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js @@ -18,7 +18,7 @@ return deferred.promise; }, - SendMailToUser: function (userInfo, isPassword) { + SendMailToUser: function (userInfo, havePassword) { var deferred = $q.defer(); $http.post('/API/api/ForgotUser', userInfo, { //JSON.stringify(userEmail) -- libgit2 0.21.4