From 0fd23b0d05bb574e34d7001d3ea0cf82e75eaa53 Mon Sep 17 00:00:00 2001 From: Utkarsh Singh Date: Wed, 8 Mar 2017 18:07:26 +0530 Subject: [PATCH] Committed code --- 400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj | 3 ++- 400-SOURCECODE/AIAHTML5.API/Controllers/AdminAccessController.cs | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs | 164 -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs | 365 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.API/Templates/admin-Request.html | 10 ++++++++-- 400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll | Bin 30720 -> 0 bytes 400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj | 1 + 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 105 +++++++++++++++++++++++++-------------------------------------------------------------------------------- 400-SOURCECODE/AIAHTML5.Web/app/services/AdminService.js | 21 +++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html | 1 + 400-SOURCECODE/AIAHTML5.Web/index.html | 13 +++++++------ 11 files changed, 524 insertions(+), 253 deletions(-) create mode 100644 400-SOURCECODE/AIAHTML5.API/Controllers/AdminAccessController.cs delete mode 100644 400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs create mode 100644 400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs create mode 100644 400-SOURCECODE/AIAHTML5.Web/app/services/AdminService.js diff --git a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj index 1445e08..cc385d3 100644 --- a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj +++ b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj @@ -107,13 +107,14 @@ + Global.asax - + diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/AdminAccessController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/AdminAccessController.cs new file mode 100644 index 0000000..f600674 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/AdminAccessController.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using AIAHTML5.API.Constants; +using log4net; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using AIAHTML5.API.Models; +using AIAHTML5.API.Utility; + +namespace AIAHTML5.API.Controllers +{ + public class AdminAccessController : ApiController + { + // GET api/ + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api//5 + public string Get(int id) + { + return "value"; + } + + // POST api/ + //public HttpResponseMessage Post([FromBody]JObject userInfo) + //{ + // ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + // logger.Debug("inside POST in AdminAccessController for mail id = " + userInfo["emailId"]); + + // dynamic userData = AIAHTML5.API.Models.Users.GetUserByEmail(userInfo); + // if (Convert.ToString(userData) != AIAConstants.USER_NOT_FOUND && Convert.ToString(userData) != AIAConstants.ERROR_IN_FECTHING_DETAILS) + // { + // logger.Debug("inside if in AdminAccessController userData.loginId= " + userData.loginId); + // bool isMailSent = false; + // string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(userData); + + // logger.Debug("1. inside if in AdminAccessController userDetails= " + userDetails); + + // if (Convert.ToBoolean(userInfo["isAdmin"])) + // { + // logger.Debug("2: isAdmin= " + Convert.ToBoolean(userInfo["isAdmin"])); + + // isMailSent = AIAHTML5.API.Models.UserUtility.SendAdminRequestEmail(userData, Convert.ToBoolean(userInfo["isAdmin"])); + // } + // logger.Debug("isMailSent= " + isMailSent); + // if (isMailSent) + // return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userDetails) }; + // else + // return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_NOT_SENT) }; + // } + // else + // { + // logger.Debug("inside else in AdminAccessController userData= " + userData); + // return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userData) }; + // } + //} + + public HttpResponseMessage Post([FromBody]JObject userInfo) + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + logger.Debug("inside POST in AdminAccessController for mail id = " + userInfo["emailId"]); + bool isMailSent = false; + + if (Convert.ToBoolean(userInfo["isAdmin"])) + { + logger.Debug("2: isAdmin= " + Convert.ToBoolean(userInfo["isAdmin"])); + + isMailSent = AIAHTML5.API.Models.UserUtility.SendAdminRequestEmail(userInfo); + } + + logger.Debug("isMailSent= " + isMailSent); + if (isMailSent) + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("SUCCESS") }; + else + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_NOT_SENT) }; + } + + // PUT api//5 + public void Put(int id, [FromBody]string value) + { + } + + // DELETE api//5 + public void Delete(int id) + { + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs b/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs deleted file mode 100644 index 7bb2efb..0000000 --- a/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using MongoDB.Driver; -using MongoDB.Bson; -using AIAHTML5.API.Properties; -using AIAHTML5.API.Constants; -using log4net; -using System.Net.Mail; -using AIAHTML5.API.Utility; -using System.Text; -using System.IO; -using System.Net.Mime; -using System.Configuration; - -namespace AIAHTML5.API.Models -{ - public class UserUtility - { - public static bool SendEmail(dynamic UserDetails, bool isPassword) - { - ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); - logger.Debug("inside SendEmail in for isPassword =" + isPassword); - - try - { - List lstLinkedResource = new List(); - EmailUtility emailUtility = new EmailUtility(); - List lstToAddress = new List(); - List lstBccAddress = new List(); - - string emailText = string.Empty; - string userId = string.Empty; - string userMail = string.Empty; - string userName = string.Empty; - 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) - { - if (kvp.Key == "loginId") - userId = kvp.Value.ToString(); - - if (kvp.Key == "emailId") - userMail = kvp.Value.ToString(); - - if (kvp.Key == "firstName") - fName = kvp.Value.ToString(); - - if (kvp.Key == "lastName") - lName = kvp.Value.ToString(); - - if(kvp.Key == "admin") - isAdminRequest = true; - } - - string fullName = fName + " " + lName; - - string logoPath = HttpContext.Current.Server.MapPath("~/content/images/logo.png"); - - string templatePath = string.Empty; - string resetPasswordLink = string.Empty; - - if (isPassword) - { - templatePath = "~/Templates/forgot-Password.html"; - resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail); - } - else - templatePath = "~/Templates/forgot-UserId.html"; - - if(isAdminRequest) - templatePath = "~/Templates/admin-Request.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); - - lstToAddress.Add(userMail); - - emailText = mailBody; - - logger.Debug("emailText= " + emailText); - // for embedding images in email - if (emailText.Contains(" kvp in UserDetails) + { + if (kvp.Key == "loginId") + userId = kvp.Value.ToString(); + + if (kvp.Key == "emailId") + userMail = kvp.Value.ToString(); + + if (kvp.Key == "firstName") + fName = kvp.Value.ToString(); + + if (kvp.Key == "lastName") + lName = kvp.Value.ToString(); + + if (kvp.Key == "isAdmin") + isAdminRequest = Convert.ToBoolean(kvp.Value); + } + + string fullName = fName + " " + lName; + + string logoPath = HttpContext.Current.Server.MapPath("~/content/images/logo.png"); + + string templatePath = string.Empty; + string resetPasswordLink = string.Empty; + + if (isAdminRequest) + { + templatePath = "~/Templates/admin-Request.html"; + } + else + { + if (isPassword) + { + templatePath = "~/Templates/forgot-Password.html"; + resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail); + } + else + 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); + + lstToAddress.Add(userMail); + + emailText = mailBody; + + logger.Debug("emailText= " + emailText); + // for embedding images in email + if (emailText.Contains(" kvp in UserDetails) + { + if (kvp.Key == "loginId") + userId = kvp.Value.ToString(); + + if (kvp.Key == "emailId") + userMail = kvp.Value.ToString(); + + if (kvp.Key == "firstName") + fName = kvp.Value.ToString(); + + if (kvp.Key == "lastName") + lName = kvp.Value.ToString(); + } + + string fullName = fName + " " + lName; + + string logoPath = HttpContext.Current.Server.MapPath("~/content/images/logo.png"); + + string templatePath = string.Empty; + string resetPasswordLink = string.Empty; + + if (isAdmin) + { + templatePath = "~/Templates/admin-Request.html"; + } + + logger.Debug("inside SendEmail for templatePath= " + templatePath + ", userId= " + userId + ", userMail= " + userMail + ",fullName= " + fullName + ",resetPasswordLink= " + resetPasswordLink); + string mailBody = UserUtility.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, ""); + + lstToAddress.Add(userMail); + + emailText = mailBody; + + logger.Debug("emailText= " + emailText); + // for embedding images in email + if (emailText.Contains(" lstLinkedResource = new List(); + EmailUtility emailUtility = new EmailUtility(); + List lstToAddress = new List(); + List lstBccAddress = new List(); + + string emailText = string.Empty; + string userId = string.Empty; + string userMail = string.Empty; + string userName = string.Empty; + string fullName = string.Empty; + string message = string.Empty; + bool isAdmin = false; + + string site_url = Convert.ToString(ConfigurationManager.AppSettings["Site_URL"]); + + string[] mailToArr = (ConfigurationManager.AppSettings["AdminSupportStaff"]).Split(','); + for(int i=0; i
"; + + logger.Debug("emailText= " + emailText); + // for embedding images in email + if (emailText.Contains(" - Admin Access Request + Request for Admin Access   @@ -34,7 +34,13 @@   - Your request has been registered and intimated to referenced authority. + {usermessage} + + +   + + + Your request has been registered and has been intimated to referenced authority simultaneously.   diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll index 305c2d1..a0a33e2 100644 Binary files a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll and b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll differ diff --git a/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj b/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj index 73c49ce..4fe0c84 100644 --- a/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj +++ b/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj @@ -52,6 +52,7 @@ + diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 0cfed80..21b46a3 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -1,7 +1,7 @@ 'use strict'; -AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants","UserModules","LoginMessageConstants", -function ($rootScope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants) { +AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants","UserModules","LoginMessageConstants","AdminService", +function ($rootScope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService) { //$scope.pageToOpen = { // name: 'MainMenu' @@ -78,7 +78,9 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic emailId: null, isPassword: null, newPassword: null, - confirmPassword: null + confirmPassword: null, + isAdmin: null, + userMessage: null }; $rootScope.userData; $rootScope.userModules; @@ -3310,87 +3312,30 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } $rootScope.OpenAdminForm = function (userInfo) { - getUserDetails(); - if ($rootScope.userData) { - $('#fName').val(userInfo.firstName); - $('#lName').val(userInfo.lastName); - $('#email').val(userInfo.emailId); - } - /*$('#testFormAdmin').attr('display', 'block'); - $('#testFormAdmin').toggle();*/ - userInfo.firstName = 'Utkarsh'; - userInfo.lastName = 'Singh'; - userInfo.emailId = 'utkarsh.singh@ebix.com'; - if ((userInfo.emailId != null) && (userInfo.emailId != '')) { - if (validateEmail(userInfo.emailId)) { - isMailForPassword = 'admin'; - - AuthenticationService.SendMailToUser(userInfo) - .then(function (result) { - if (result == LoginConstants.USER_NOT_FOUND) { - $rootScope.errorMassage = LoginMessageConstants.INCORRECT_EMAIL_ID; - $("#messageModal").modal('show'); - } - else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) { - $rootScope.errorMassage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS; - $("#messageModal").modal('show'); - } - else if (result == LoginConstants.MAIL_NOT_SENT) { - $rootScope.errorMassage = LoginMessageConstants.MAIL_NOT_SENT; - $("#messageModal").modal('show'); - } - else { - if (result.loginId != undefined || result.loginId != "" || result.loginId != null) { - var message; - if ($('.forgot-sm').length > 0) { - $('.forgot-sm').fadeOut(); - $('.forgot-sm').modal('hide'); - } - if ($('.forgot-sm1').length > 0) { - $('.forgot-sm1').fadeOut(); - $('.forgot-sm1').modal('hide'); - } - if (isMailForPassword) - message = LoginMessageConstants.RESET_PASSWORD; - else - message = LoginMessageConstants.USERID_SENT_IN_EMAIL - //alert(message); - $rootScope.errorMassage = message; - $("#messageModal").modal('show'); - - - } - } + //if ($rootScope.userData) { + $('#fName').val('Utkarsh'); + $('#lName').val('Singh'); + $('#emailId').val('utkarsh.singh@ebix.com'); + //} + }; - }, - function (error) { - console.log(' Error in authentication = ' + error.statusText); - // alert(LoginConstants.ERROR_IN_FECTHING_DETAILS); - $rootScope.errorMassage = LoginConstants.ERROR_IN_FECTHING_DETAILS; - $("#messageModal").modal('show'); - }); - } - else { - // alert(LoginMessageConstants.INCORRECT_EMAIL_ID); - $rootScope.errorMassage = LoginMessageConstants.INCORRECT_EMAIL_ID; - $("#messageModal").modal('show'); - } + $rootScope.SendAdminAccessRequestMail = function (userInfo) { + userInfo.isAdmin = true; + if ($rootScope.userData) { } - else { - //alert(LoginMessageConstants.BLANK_EMAIL_ID); - $rootScope.errorMassage = LoginMessageConstants.BLANK_EMAIL_ID; - $("#messageModal").modal('show'); - } - }; + userInfo.firstName = "Utkarsh"; + userInfo.lastName = "Singh"; + userInfo.emailId = "utkarsh.singh@ebix.com"; + var msg = $('#userMessage').text(); + if (userInfo.userMessage==null) + userInfo.userMessage = msg; - /*function SendMailFromAdmin(userInfo, isMailForPassword) { if ((userInfo.emailId != null) && (userInfo.emailId != '')) { if (validateEmail(userInfo.emailId)) { - isMailForPassword = 'admin'; - AuthenticationService.SendMailToUser(userInfo) + AdminService.SendAdminRequestMail(userInfo) .then(function (result) { if (result == LoginConstants.USER_NOT_FOUND) { $rootScope.errorMassage = LoginMessageConstants.INCORRECT_EMAIL_ID; @@ -3415,9 +3360,9 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $('.forgot-sm1').fadeOut(); $('.forgot-sm1').modal('hide'); } - if (isMailForPassword) - message = LoginMessageConstants.RESET_PASSWORD; - else + //if (isMailForPassword) + // message = LoginMessageConstants.RESET_PASSWORD; + //else message = LoginMessageConstants.USERID_SENT_IN_EMAIL //alert(message); $rootScope.errorMassage = message; @@ -3447,7 +3392,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#messageModal").modal('show'); } - };*/ + }; }] ); \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/AdminService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/AdminService.js new file mode 100644 index 0000000..1cedf01 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AdminService.js @@ -0,0 +1,21 @@ +AIA.factory('AdminService', function ($http, $q) { + return { + SendAdminRequestMail: function (userInfo) { + var deferred = $q.defer(); + + $http.post('/API/api/AdminAccess', userInfo, { //JSON.stringify(userEmail) + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success'); + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(status); + }); + return deferred.promise; + } + } +}); \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html b/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html index 51dff7b..8bc3f26 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html @@ -89,3 +89,4 @@ + \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/index.html b/400-SOURCECODE/AIAHTML5.Web/index.html index 67cd63a..b2765bd 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.html +++ b/400-SOURCECODE/AIAHTML5.Web/index.html @@ -1177,26 +1177,26 @@
- +
- +
- +
- +
@@ -1331,6 +1331,7 @@ + -- libgit2 0.21.4