diff --git a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj index 8147fb3..584026e 100644 --- a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj +++ b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj @@ -106,13 +106,14 @@ + Global.asax - + diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs index acb5195..63f2c5c 100644 --- a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs +++ b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs @@ -10,7 +10,7 @@ namespace AIAHTML5.API.Constants public const string ERROR_IN_FECTHING_DETAILS = "Error in fecthing details."; public const string USER_NOT_FOUND = "User not found."; public const string MAIL_NOT_SENT = "Mail not sent."; - + public const string MAIL_SENT = "Mail has been sent."; } diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/AdminAccessController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/AdminAccessController.cs new file mode 100644 index 0000000..e571377 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/AdminAccessController.cs @@ -0,0 +1,36 @@ +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 + { + public HttpResponseMessage Post([FromBody]JObject userInfo) + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + + bool isMailSent = AIAHTML5.API.Models.UserUtility.SendAdminRequestEmail(userInfo); + + if (isMailSent) + { + logger.Debug("AdminAccessRequest mail sent for User: " + userInfo["firstName"] + " " + userInfo["lastName"] + "& mail id = " + userInfo["emailId"]); + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_SENT) }; + } + else + { + logger.Debug("AdminAccessRequest mail sent for User: " + userInfo["firstName"] + " " + userInfo["lastName"] + "& mail id = " + userInfo["emailId"]); + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_NOT_SENT) }; + } + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs index e0ef377..f364ee9 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs @@ -49,13 +49,13 @@ namespace AIAHTML5.API.Controllers { logger.Debug("2. isPassword= " + Convert.ToBoolean(userInfo["isPassword"])); - isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, true); + isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, true); } else { logger.Debug("3. isPassword= " + Convert.ToBoolean(userInfo["isPassword"])); - isMailSent = AIAHTML5.API.Models.ResetUser.SendEmail(userData, false); + isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, false); } logger.Debug("isMailSent= " + isMailSent); if (isMailSent) diff --git a/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs index e90deb6..11cbcc6 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs @@ -12,15 +12,15 @@ using AIAHTML5.API.Utility; using System.Text; using System.IO; using System.Net.Mime; -using System.Configuration; +using System.Configuration; namespace AIAHTML5.API.Models { - public class ResetUser + public class UserUtility { public static bool SendEmail(dynamic UserDetails, bool isPassword) - { - ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); logger.Debug("inside SendEmail in for isPassword =" + isPassword); try @@ -37,6 +37,7 @@ 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) { @@ -51,6 +52,9 @@ namespace AIAHTML5.API.Models if (kvp.Key == "lastName") lName = kvp.Value.ToString(); + + if (kvp.Key == "isAdmin") + isAdminRequest = Convert.ToBoolean(kvp.Value); } string fullName = fName + " " + lName; @@ -60,21 +64,29 @@ namespace AIAHTML5.API.Models string templatePath = string.Empty; string resetPasswordLink = string.Empty; - if (isPassword) + if (isAdminRequest) { - templatePath = "~/Templates/forgot-Password.html"; - resetPasswordLink = site_url + "?em:" + HttpUtility.UrlEncode(userMail); + templatePath = "~/Templates/admin-Request.html"; } else - templatePath = "~/Templates/forgot-UserId.html"; - + { + 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 = ResetUser.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, resetPasswordLink); + string mailBody = UserUtility.GetMailBodyTextFromTemplate(templatePath, userId, userMail, fullName, resetPasswordLink); lstToAddress.Add(userMail); - emailText = mailBody; - + 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 userId = string.Empty; + string userMail = string.Empty; + string userName = string.Empty; + string fullName = string.Empty; + string emailMessage = string.Empty; + + string[] mailToArr = (ConfigurationManager.AppSettings["AdminSupport"]).Split(','); + if (mailToArr.Length > 0) + { + for (int i = 0; i < mailToArr.Length; i++) + { + lstToAddress.Add(mailToArr[i].ToString()); + } + } + + fullName = userInfo["firstName"].ToString() + " " + userInfo["lastName"].ToString(); + 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(" - + + diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll index e86cb00..5f45e5f 100644 --- a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll +++ b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config index 6cc6c46..92603bf 100644 --- a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config +++ b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll.config @@ -39,7 +39,8 @@ - + + diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb index 9f3e265..564e5c5 100644 --- a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb +++ b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 6d182b1..0504955 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", "AdminConstants", "UserTypeConstants", +function ($rootScope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, AdminConstants, UserTypeConstants) { //$scope.pageToOpen = { // name: 'MainMenu' @@ -77,12 +77,14 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic emailId: null, isPassword: null, newPassword: null, - confirmPassword: null + confirmPassword: null, + userMessage: null }; $rootScope.userData; $rootScope.userModules; $rootScope.errorMesaage; $rootScope.isVisibleLogin; + $rootScope.notAnAdmin; var isfilloptionChecked = ""; var isOutlineOptionChecked = ""; $rootScope.initializeAIA = function () { @@ -134,6 +136,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.isVisibleLogin = false; localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + + var userType = result.userType + ''; + + if (userType === UserTypeConstants.SUPER_ADMIN) + $rootScope.notAnAdmin = false; + else + $rootScope.notAnAdmin = true; } } } @@ -3287,5 +3296,53 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } + $rootScope.OpenAdminForm = function (userInfo) { + $('#adminModal').css({ top: '50px' }); + if ($rootScope.userData) { + $('#adminfName').val($rootScope.userData.firstName); + $('#adminlName').val($rootScope.userData.lastName); + $('#adminEmailId').val($rootScope.userData.emailId); + } + }; + + $rootScope.SendAdminAccessRequestMail = function (userInfo) { + + if ($rootScope.userData) { + userInfo.firstName = $rootScope.userData.firstName; + userInfo.lastName = $rootScope.userData.lastName; + userInfo.emailId = $rootScope.userData.emailId; + } + + if (userInfo.userMessage != undefined && userInfo.userMessage != '' && userInfo.userMessage != null) { + + AdminService.SendAdminAccessRequestMail(userInfo) + .then(function (result) { + if (result == AdminConstants.MAIL_SENT) { + $("#adminModal").fadeOut(); + $("#adminModal").modal('hide'); + $("adminAccessTextArea").text(''); + + $rootScope.errorMassage = AdminConstants.ADMIN_ACCESS_REQUEST_SUCCESS; + $("#messageModal").modal('show'); + } + }, + function (error) { + console.log(' Error in intimating admin support = ' + error.statusText); + $rootScope.errorMassage = AdminConstants.ERROR_IN_SENDING_MAIL; + $("#messageModal").modal('show'); + }); + } + else { + $rootScope.errorMassage = AdminConstants.EMPTY_MESSAGE; + $("#spnError").text(AdminConstants.EMPTY_MESSAGE); + + } + }; + + $rootScope.CloseAAModal = function () { + $("#adminModal").fadeOut(); + $("#adminModal").modal('hide'); + $("adminAccessTextArea").text(''); + } }] ); \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js index 1df1b47..1f04cc1 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js @@ -310,6 +310,23 @@ AIA.constant("LoginMessageConstants", { //"MAIL_NOT_SENT": "Mail not sent." }) +AIA.constant("AdminConstants", { + "ADMIN_ACCESS_REQUEST_SUCCESS": "Mail has been sent to referenced authority.", + "EMPTY_MESSAGE": "Please, type some message before submitting.", + "ERROR_IN_SENDING_MAIL": "Some internal error occured.", + "MAIL_SENT": "Mail has been sent." +}) +AIA.constant("UserTypeConstants", { + "SUPER_ADMIN": "Super Admin", + "GENERAL_ADMIN": "General Admin", + "DISTRICT_ADMIN": "District Admin", + "CLIENT_ADMIN": "Client Admin", + "SINGLE_USER": "Single User", + "CONCURRENT_USER": "Concurrent User", + "RESELLER": "Reseller", + "TEST_ACCOUNT": "Test Account", + "SITE_USER": "Site User" +}) AIA.constant("UserModules", [ { "name": "Dissectible Anatomy", 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..f4f581d --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AdminService.js @@ -0,0 +1,21 @@ +AIA.factory('AdminService', function ($http, $q) { + return { + SendAdminAccessRequestMail: function (userInfo) { + var deferred = $q.defer(); + + $http.post('/API/api/AdminAccess', userInfo, { + 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 9699079..9679625 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html @@ -49,7 +49,7 @@
  • About A.D.A.M.
  • -
  • Admin
  • +
  • Admin