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..6342e8e 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 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..2d705a2 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs @@ -45,17 +45,17 @@ 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.ResetUser.SendEmail(userData, true); + 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.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..f42e1ab 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/ResetUser.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs @@ -12,16 +12,16 @@ 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)); - logger.Debug("inside SendEmail in for isPassword =" + 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 =" + havePassword); try { @@ -38,19 +38,19 @@ namespace AIAHTML5.API.Models string lName = string.Empty; string site_url = Convert.ToString(ConfigurationManager.AppSettings["Site_URL"]); - 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 (userObj.Key == "lastName") + lName = userObj.Value.ToString(); } string fullName = fName + " " + lName; @@ -60,21 +60,21 @@ namespace AIAHTML5.API.Models string templatePath = string.Empty; string resetPasswordLink = string.Empty; - if (isPassword) + if (havePassword) { 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 = 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(" lstToAddress = new List(); + List lstBccAddress = new List(); + + string userMail = 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(); + + lstToAddress.Add(userMail); + + emailMessage = emailMessage.Replace("\n", ""); + + emailMessage += ""; + + string mailSubject = "Admin Support request initiated for:"; + + emailUtility.sHostName = Convert.ToString(ConfigurationManager.AppSettings["HostAddress"]); + emailUtility.sFromAddress = Convert.ToString(ConfigurationManager.AppSettings["SenderEmailAddress"]); + emailUtility.bIsBodyHtml = true; + emailUtility.bEnableSsl = false; + emailUtility.sSubject = mailSubject + " " + userMail; + emailUtility.sBodyText = emailMessage; + emailUtility.iPort = 25; + emailUtility.sToAddresses = lstToAddress; + emailUtility.sBccAddresses = lstBccAddress; + + emailUtility.SendSmtpEmail(); + return true; + } + catch (Exception ex) + { + logger.Fatal("exception in GetMailBodyTextFromTemplate. msg= " + ex.Message + ", stacktrace= " + ex.StackTrace); + return false; + } + } + } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Web.config b/400-SOURCECODE/AIAHTML5.API/Web.config index 6cc6c46..92603bf 100644 --- a/400-SOURCECODE/AIAHTML5.API/Web.config +++ b/400-SOURCECODE/AIAHTML5.API/Web.config @@ -39,7 +39,8 @@ - + + 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..77b7823 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..4e011b7 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' @@ -75,14 +75,16 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic username: null, password: null, emailId: null, - isPassword: null, + havePassword: 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; } } } @@ -193,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) { @@ -3287,5 +3296,45 @@ 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; + } + + AdminService.SendAdminAccessRequestMail(userInfo) + .then(function (result) { + if (result == AdminConstants.MAIL_SENT) { + $("#adminModal").fadeOut(); + $("#adminModal").modal('hide'); + $("adminAccessTextArea").text(''); + + $rootScope.errorMassage = AdminConstants.MAIL_SENT; + $("#messageModal").modal('show'); + } + }, + function (error) { + console.log(' Error in sending mail to admin support = ' + error.statusText); + $rootScope.errorMassage = AdminConstants.ERROR_IN_SENDING_MAIL; + $("#messageModal").modal('show'); + }); + }; + + $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..f4a4f10 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js @@ -310,6 +310,21 @@ AIA.constant("LoginMessageConstants", { //"MAIL_NOT_SENT": "Mail not sent." }) +AIA.constant("AdminConstants", { + "ERROR_IN_SENDING_MAIL": "Some internal error occured.", + "MAIL_SENT": "Mail 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/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) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html b/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html index 3651d42..5aff6fd 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 Logout diff --git a/400-SOURCECODE/AIAHTML5.Web/index.html b/400-SOURCECODE/AIAHTML5.Web/index.html index 15262dd..4caeee1 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.html +++ b/400-SOURCECODE/AIAHTML5.Web/index.html @@ -1164,6 +1164,57 @@ + + + + + + × + *This module is not yet available to use, please fill in the form with complete details, a support request will be submitted to ADAM Education Sales and Support team. If needed someone from ADAM team will contact you ASAP. + + + + + + + First Name : + + + + + + Last Name : + + + + + + Email Id * : + + + + + + Message * : + + + Message required. + + + + + Submit + + + + + + + + + + + +