From 3e67cc40a178ef66086517ceb16543227de54210 Mon Sep 17 00:00:00 2001 From: Birendra Date: Mon, 9 Aug 2021 13:50:47 +0530 Subject: [PATCH] add CA url login to AIA --- 400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj | 1 + 400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs | 2 ++ 400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs | 2 ++ 400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs | 7 ++++--- 400-SOURCECODE/AIAHTML5.API/Controllers/UrlLoginController.cs | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.API/Models/User.cs | 2 ++ 400-SOURCECODE/AIAHTML5.API/Models/Users.cs | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.Web/app/controllers/CAController.js | 89 ++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 332 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------- 400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js | 22 ++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.Web/app/views/ca/ca-view.html | 4 ++-- 400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html | 2 +- 400-SOURCECODE/AIAHTML5.Web/app/widget/MainView.html | 2 +- 400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html | 4 ++-- 400-SOURCECODE/AIAHTML5.Web/libs/jquery/jquery_plugin/jsPanel/jspanel/jquery.jspanel.js | 10 +++++++++- 16 files changed, 675 insertions(+), 142 deletions(-) create mode 100644 400-SOURCECODE/AIAHTML5.API/Controllers/UrlLoginController.cs diff --git a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj index e0b819e..3b104ce 100644 --- a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj +++ b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj @@ -128,6 +128,7 @@ + Global.asax diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs index 1e9fee5..9993ff3 100644 --- a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs +++ b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs @@ -51,6 +51,8 @@ namespace AIAHTML5.API.Constants public const string INVALID_CLIENT = "InValid Client."; public const string MSG_NOT_AUTHORIZE_SITE_USER = "User is not authorized."; public const string SETTINGS_SAVE_FAILURE = "We are unable to save your Settings. Please try again."; + public const string INVALID_URL = "InValid URL. Please try again."; + public const string INVALID_LOGIN = "InValid Login."; public const string STATUS_OK = "ok"; public const string STATUS_NOT_OK = "notok"; diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs index bfaf6d8..0820160 100644 --- a/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs +++ b/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs @@ -45,5 +45,7 @@ namespace AIAHTML5.API.Constants public const string GET_AOD_AUTHENTICATION_STATUS = "usp_AodAuthenticationStatus"; public const string INSERT_SITE_LOGIN_LOG = "usp_InsertSiteLoginLog"; public const string GET_AOD_COURSE_ITEMS = "GetSelectedCoursesToLicense"; + public const string GET_LOGIN_BY_URL = "usp_GetLoginByUrl"; + public const string GET_STUDENT_EDITION = "usp_GetEditionByLicenseId"; } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs index 33ac18a..e33f313 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs @@ -335,12 +335,12 @@ namespace AIAHTML5.API.Controllers else { //check Modesty settings for this license - userInfo.IsModestyOn = AIAHTML5.API.Models.Users.IsModestyActiveForThisLicense(userInfo.LicenseId, Convert.ToInt16(userInfo.EditionId)); - } - } + // add editon number for provide CA link + userInfo.StudentEdition = AIAHTML5.API.Models.Users.GetStudentEdition(userInfo.LicenseId); + } else { ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); @@ -497,6 +497,7 @@ namespace AIAHTML5.API.Controllers [Route("api/ByPassLoginToOpenModule")] public HttpResponseMessage ByPassLoginToOpenModule([FromBody]JObject sitedetail) { + // note:created new UrlLoginController for bypass login dynamic responseData; BypassLogin objUser = null; diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/UrlLoginController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/UrlLoginController.cs new file mode 100644 index 0000000..f55fda2 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/UrlLoginController.cs @@ -0,0 +1,93 @@ +using AIAHTML5.API.Constants; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using AIAHTML5.API.Models; +using Newtonsoft.Json.Linq; +using System.Data.SqlClient; +using System.Collections; +using log4net; +using Newtonsoft.Json; +using System.Data; + +namespace AIAHTML5.API.Controllers +{ + public class UrlLoginController : ApiController + { + // POST api/UrlLogin + public HttpResponseMessage Post([FromBody]JObject loginUrl) + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + logger.Debug("inside POST in UrlLoginController"); + try{ + HttpResponseMessage response = null; + if (loginUrl != null) + { + if (!string.IsNullOrEmpty(loginUrl["accountNumber"].ToString()) && !string.IsNullOrEmpty(loginUrl["edition"].ToString())) + { + var EditionId = Convert.ToInt32(loginUrl["edition"].ToString()); + var accountNumber = loginUrl["accountNumber"].ToString(); + var mType= loginUrl["mType"].ToString(); + string slug = string.Empty; + + int licId = AIAHTML5.API.Models.Users.ValidateLicenseByLoginUrl(accountNumber, EditionId); + + if (licId>0) + { + if(mType.ToUpper()=="CA") + { + slug = "clinical-animations"; + } + else if(mType.ToUpper() == "DA") + { + slug = "da-view-list"; + } + + dynamic uerinfo = AIAHTML5.API.Models.Users.ValidateLoginByUrl(accountNumber, EditionId, licId, slug); + if (uerinfo != null) + { + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(uerinfo)) }; + } + else + { + logger.Debug("INVALID_LOGIN"); + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.INVALID_LOGIN) }; + } + } + else + { + logger.Debug("NOT AUTHORIZED"); + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MSG_NOT_AUTHORIZE_SITE_USER) }; + + } + } + else + { + logger.Debug("INVALID URL"); + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.INVALID_URL) }; + + } + } + else + { + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = null }; + + } + return response; + } + catch (SqlException e) + { + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; + } + catch (Exception e) + { + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; + + } + } + + } +} diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index c93417d..4b5a14e 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -165,6 +165,57 @@ namespace AIAHTML5.API.Models return hash; } + internal ArrayList GetUserModulesBySlug(int licenseId,string slug) + { + logger.Debug(" Inside GetUserModulesByLicenseId for LicenseId = " + licenseId); + + ArrayList userModulelist = new ArrayList(); + + Hashtable modulesHash; + DataSet ds = new DataSet(); + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + SqlDataAdapter adapter; + SqlParameter param; + + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_USER_MODULES_BY_LICENSE_ID; + cmd.CommandType = CommandType.StoredProcedure; + + param = new SqlParameter("@iLicenseId", licenseId); + param.Direction = ParameterDirection.Input; + param.DbType = DbType.Int32; + cmd.Parameters.Add(param); + + adapter = new SqlDataAdapter(cmd); + adapter.Fill(ds); + + + if (ds != null && ds.Tables.Count > 0) + { + DataTable dt = ds.Tables[0]; + + if (dt.Rows.Count > 0) + { + foreach (DataRow dr in dt.Rows) + { + if(dr["Slug"].ToString()== slug) + { + modulesHash = new Hashtable(); + modulesHash.Add(AIAConstants.KEY_ID, dr["Id"]); + modulesHash.Add(AIAConstants.KEY_NAME, dr["Title"]); + modulesHash.Add(AIAConstants.KEY_SLUG, dr["Slug"]); + userModulelist.Add(modulesHash); + } + + } + } + } + + + return userModulelist; + } internal ArrayList GetUserModulesByLicenseId(int licenseId) { logger.Debug(" Inside GetUserModulesByLicenseId for LicenseId = " + licenseId); @@ -1309,6 +1360,27 @@ namespace AIAHTML5.API.Models // return 1; //} + internal DataTable GetLoginbyUrl(string licenceAccount, int editionId) + { + logger.Debug(" inside GetLicenseIdBySiteUrl for UserId= " + editionId + ",licenceAccount = " + licenceAccount); + + // SiteUrl siteUrl = null; + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_LOGIN_BY_URL; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@sLicenseAccount", licenceAccount); + cmd.Parameters.AddWithValue("@iEditionId", editionId); + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + return dt; + } internal DataTable GetLicenseInfoBySiteUrl(string licenceAccount, int editionId) { @@ -1495,5 +1567,37 @@ namespace AIAHTML5.API.Models return isModestyOn; } + internal List GetStudentEditionByLicenseId(int LicenseId) + { + List arrayEditionList = new List(); + + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_STUDENT_EDITION; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@iLicenseId", LicenseId); + + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + if (dt != null && dt.Rows.Count > 0) + { + if(arrayEditionList.Count<1) + { + // geting only first editon 3 or 4 + string edition = dt.Rows[0]["EditionId"].ToString(); + arrayEditionList.Add(edition); + } + + } + + return arrayEditionList; + } + } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/User.cs b/400-SOURCECODE/AIAHTML5.API/Models/User.cs index 3848846..cf8effe 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/User.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/User.cs @@ -58,6 +58,8 @@ namespace AIAHTML5.API.Models public string TermsAndConditionsTitle { get; set; } public string TermsAndConditionsText { get; set; } + public List StudentEdition { get; set; } + public const string SUPER_ADMIN = "Super Admin"; public const string GENERAL_ADMIN = "General Admin"; public const string DISTRICT_ADMIN = "District Admin"; diff --git a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs index 88d467a..5ac9e20 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs @@ -205,6 +205,20 @@ namespace AIAHTML5.API.Models return isLicenseExpired; } + internal static ArrayList getModuleListBySlug(int licenseId,string slug) + { + logger.Debug("inside getModuleListByLicenseId for LicenseId =" + licenseId); + + ArrayList licensedModulesList = new ArrayList(); + + + + DBModel objModel = new DBModel(); + licensedModulesList = objModel.GetUserModulesBySlug(licenseId,slug); + + + return licensedModulesList; + } internal static ArrayList getModuleListByLicenseId(int licenseId) { logger.Debug("inside getModuleListByLicenseId for LicenseId =" + licenseId); @@ -698,5 +712,132 @@ namespace AIAHTML5.API.Models bool IsModestyOn = objModel.GetModestyInfo(LicenseId,editionId); return IsModestyOn; } + + internal static List GetStudentEdition(int LicenseId) + { + DBModel objModel = new DBModel(); + List arrayEditionList = objModel.GetStudentEditionByLicenseId(LicenseId); + + return arrayEditionList; + } + + public static int ValidateLicenseByLoginUrl(string strAccountNumber, int editionId) + { + int intReturn = 0; + DBModel objDBModel = new DBModel(); + DataTable dtLicense = objDBModel.GetLoginbyUrl(strAccountNumber, editionId); + + if (dtLicense.Rows.Count > 0) + { + foreach (DataRow objLicenseRow in dtLicense.Rows) + { + intReturn = Convert.ToInt32(objLicenseRow["Id"]); + } + + } + + return intReturn; + } + + public static User ValidateLoginByUrl(String strAcccountNumber, int intEditionId, int licId, string slug) + { + User userInfo = null; + + string expirationDate = null; + bool isLicenseExpired = false; + + // validate license start date + string startDate = null; + bool isSubscriptionNotStart = false; + + DateTime dtLogDate = DateTime.Now; + + if (string.IsNullOrEmpty(strAcccountNumber)) + { + userInfo.LoginFailureCauseId = ErrorHelper.E_ACCOUNT_NUMBER_NOT_NULL; + } + else if (intEditionId == 0) + { + userInfo.LoginFailureCauseId = ErrorHelper.E_EDITION_ID_NOT_NULL; + } + else + { + userInfo = new User(); + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(licId); + + if (userInfo.LicenseInfo != null) + { + //05.3 get licenseSubscription details + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseInfo.Id); + + //05.4 check the License expiration irespective of either user is active or not because on AIA + //we shows the License expiration message for inactive users too + + if (userInfo.LicenseSubscriptions != null) + { + isSubscriptionNotStart = AIAHTML5.API.Models.Users.checkIfLicenseNotStarted(userInfo.LicenseSubscriptions, out startDate); + + isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate); + } + + if (userInfo.LicenseInfo.IsActive != true) + { + userInfo.LoginFailureCauseId = ErrorHelper.LICENSE_INACTIVE; + } + else if (isLicenseExpired) + { + userInfo.LoginFailureCauseId = ErrorHelper.LICENSE_EXPIRED; + userInfo.SubscriptionExpirationDate = expirationDate; + } + else if (isSubscriptionNotStart) + { + userInfo.LoginFailureCauseId = ErrorHelper.LICENSE_NOTSTARTED; + userInfo.SubscriptionStartDate = startDate; + + } + else + { + //User objUserContext = new User(); + userInfo.Id = 0; + userInfo.siteId = 0; + userInfo.isSiteUser = true; //using as site user + userInfo.FirstName = userInfo.LicenseInfo.LicenseeFirstName; + userInfo.LastName = userInfo.LicenseInfo.LicenseeLastName; + userInfo.LicenseId = licId; + userInfo.UserTypeId = AIAConstants.SITE_USER; + + userInfo.AccountNumber = strAcccountNumber; + userInfo.EditionId = (Byte)intEditionId; + userInfo.LicenseTypeId = (Byte)userInfo.LicenseInfo.LicenseTypeId; + + // below detail not using + userInfo.LicenseEditionId = 0; + userInfo.LoginId = ""; + userInfo.Modesty = true; + userInfo.ModestyMode = true; + userInfo.userselectedModesty = null; + userInfo.userSelectedSkintone = null; + userInfo.userLexicon = null; + + // get only CA module + + userInfo.Modules = getModuleListBySlug(licId,slug); + + } + + + } + else + { + + userInfo.LoginFailureCauseId = ErrorHelper.E_EDITION_NOT_LINKED_WITH_SITE; + } + + + } + + return userInfo; + } + } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CAController.js index f304eda..2062bc9 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CAController.js @@ -162,9 +162,9 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout //direct open CA module var curtab = $rootScope.getLocalStorageValue("currentCATabView"); $scope.setActiveTab(curtab) - if($rootScope.siteUrlInfo.mtype!=null && $rootScope.siteUrlInfo.id!=null) + if($rootScope.siteUrlInfo.mType!=null && $rootScope.siteUrlInfo.id!=null) { - if($rootScope.siteUrlInfo.mtype.toLowerCase()=='ca' && $rootScope.siteUrlInfo.id!="") + if($rootScope.siteUrlInfo.mType.toLowerCase()=='ca' && $rootScope.siteUrlInfo.id!="") { $rootScope.isCallFromOtherModule = true; $rootScope.linkToOpenCa=true; @@ -184,43 +184,47 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout .where('_id = ' + $rootScope.siteUrlInfo.id) .select('_Title'); - if(AnimationTitle.length>0) - { - var CAlinkData = { - "id": $rootScope.siteUrlInfo.id, - "mType": 'CLINICAL_ANIMATIONS', - "textVisible": true, - "maximised": true, - "windowTitle": AnimationTitle[0]._Title, - - }; - - ModuleService.setModuleData(CAlinkData, 0); - // close/remove prev panel when in minimised mode - - if($rootScope.CAWindowData!=undefined) + if(AnimationTitle.length>0) { - if($rootScope.CAWindowData.length>0) + var CAlinkData = { + "id": $rootScope.siteUrlInfo.id, + "mType": 'CLINICAL_ANIMATIONS', + "textVisible": true, + "maximised": true, + "windowTitle": AnimationTitle[0]._Title, + + }; + + ModuleService.setModuleData(CAlinkData, 0); + // close/remove prev panel when in minimised mode + + if($rootScope.CAWindowData!=undefined) { - for(var x=0 ;x < $rootScope.CAWindowData.length;x++){ - var winid=$rootScope.CAWindowData[x].multiwinid; - if ($('#caImagePanel_' + winid).html() != undefined) { - $('#caImagePanel_' + winid).remove(); - } + if($rootScope.CAWindowData.length>0) + { + for(var x=0 ;x < $rootScope.CAWindowData.length;x++){ + var winid=$rootScope.CAWindowData[x].multiwinid; + if ($('#caImagePanel_' + winid).html() != undefined) { + $('#caImagePanel_' + winid).remove(); + } + } + $rootScope.CAWindowData=[]; } - $rootScope.CAWindowData=[]; } + + $location.url('/clinical-animations-detail'); } - - $location.url('/clinical-animations-detail'); - } - else - { - $('#errorMessage').text("Animation course not found. Please try again!"); - $("#messageModal").modal('show'); - - } - + else + { + $("#messageModal div div .modal-header button").css('display','none'); + $('#errorMessage').text("Animation course not found. Please try again!"); + $("#messageModal").modal('show'); + + //logout if not course found + $("#messageModal div div .modal-footer button").on('click', function (event) { + $rootScope.LogoutUser(); + }); + } }, function (error) { $scope.EnableUI(); @@ -309,7 +313,8 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout //call time interval function until load Illustration data var timeintval = null; timeintval = $interval(function () { - var AnimationData = $scope.GetCAwindowStoreData($rootScope.MULTI_VIEW_ID, 'AnimationData'); + var AnimationData = $scope.GetCAwindowStoreData($rootScope.MULTI_VIEW_ID, 'AnimationData'); + if(AnimationData==undefined){$scope.stopIntervalCA();} if (AnimationData.length>0) { $scope.stopIntervalCA(); if (curtab == 2) { @@ -385,7 +390,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout promise.then( function (result) { - if($rootScope.userData.Id>1 && $rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2) + if($rootScope.userData.Id>1 && $rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2 && $rootScope.userData.StudentEdition!= null && $rootScope.userData.StudentEdition.length>0) { $scope.islinkActive = true; var AnimationData = new jinqJs() @@ -395,7 +400,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout angular.forEach(AnimationData, function (value, key) { - AnimationData[key].copyLink=$rootScope.homeURL+'?username='+$rootScope.userData.LoginId+'&accountNumber='+$rootScope.userData.LicenseInfo.AccountNumber.trim()+'&mtype=CA&id='+value._id; + AnimationData[key].copyLink=$rootScope.homeURL+'?accountNumber='+$rootScope.userData.LicenseInfo.AccountNumber.trim()+'&edition='+$rootScope.userData.StudentEdition[0]+'&referer=&mType=CA&id='+value._id; }); @@ -430,7 +435,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout angular.forEach($scope.selectedCAListViewData, function (value, key) { var imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage; - if($rootScope.userData.Id>1 && $rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2) + if($rootScope.userData.Id>1 && $rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2 && $rootScope.userData.StudentEdition!= null && $rootScope.userData.StudentEdition.length>0) { var $el = $('
' +'
' @@ -439,7 +444,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout + '

' + value._Title + '

' +'
' +'
' - +'' + +'' +'
' +'').appendTo('#grid-view'); @@ -670,10 +675,8 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout } if (selectimg === true && count >= filtercount) { - - var imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage; - if($rootScope.userData.Id>1 && $rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2) + if($rootScope.userData.Id>1 && $rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2 && $rootScope.userData.StudentEdition!= null && $rootScope.userData.StudentEdition.length>0) { var $el = $('
' +'
' @@ -682,7 +685,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout + '

' + value._Title + '

' +'
' +'
' - +'' + +'' +'
' +'').appendTo('#grid-view'); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 62ad8b6..ed0be48 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -655,6 +655,10 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data emailId: null, newPassword: null, confirmPassword: null, + accountNumber: null, + edition: null, + mType:null, + urlReferer: null, userMessage: null, unblockUser: false, isMailForForgotPassword: false, @@ -671,7 +675,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data calsCreds: null, userId: null, password: null, - mtype:null, + mType:null, id:null, SessionId:date.getTime() } @@ -726,11 +730,11 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data //licenseId would be zero for admin/gernal admin var isadminType=loggedInUser.LicenseId==0?true:false; - if(loggedInUser.mtype!=undefined) + if(loggedInUser.mType!=undefined) { $scope.checkuserstatus = { userId: userId, - tagName: loggedInUser.mtype.toLowerCase()=='ca'?'logout':'update', + tagName: loggedInUser.mType.toLowerCase()=='ca'?'logout':'update', SessionId:loggedInUser.SessionId, isSiteUser:loggedInUser.isSiteUser, isAdmin:isadminType @@ -1032,13 +1036,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data result.aiaIdleTime=$rootScope.aiaIdleTime; result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut; result.aiaPingInterval=$rootScope.aiaPingInterval; - result.SessionId=userInfo.SessionId; - if(userInfo.mtype!=undefined) - { - //for CA bypass login - result.mtype=userInfo.mtype; - } - + result.SessionId=userInfo.SessionId; //display user name $rootScope.userName=result.FirstName+" "+result.LastName; @@ -1261,14 +1259,9 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data $rootScope.isVisibleLogin = false; } - $location.path('/'); - - $timeout(function () { - $rootScope.LoginEnableUI(); - $scope.RedirectToModule(); - }, 100); - + $rootScope.LoginEnableUI(); + } else { @@ -1350,13 +1343,10 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data $(".modal-backdrop").css("opacity", ".5"); } - else { + else + { $location.path('/'); - $timeout(function () { - $rootScope.LoginEnableUI(); - $scope.RedirectToModule(); - - }, 100); + $rootScope.LoginEnableUI(); } } else { @@ -1401,12 +1391,11 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data } $scope.RedirectToModule = function () { - if($rootScope.siteUrlInfo.mtype!=null && $rootScope.siteUrlInfo.id!=null) + if($rootScope.siteUrlInfo.mType!=null && $rootScope.siteUrlInfo.id!=null) { - if($rootScope.siteUrlInfo.mtype.toLowerCase()=='ca' && $rootScope.siteUrlInfo.id!="") + if($rootScope.siteUrlInfo.mType.toLowerCase()=='ca' && $rootScope.siteUrlInfo.id!="") { $('#clinical-animations').trigger('click'); - $rootScope.isCAlink=true; } } @@ -1419,7 +1408,8 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data $scope.ValidateClientSiteUrl = function () { $rootScope.isCallFromSite = true; - + $rootScope.isCAlink=true; + $rootScope.LoginDisableUI(); var siteInfo = params.split('&'); for (var i = 0; i < siteInfo.length; i++) { @@ -1433,23 +1423,23 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data //added by birendra direct open CA module if(paramInfo[0].toLowerCase() == 'mtype') { - $rootScope.siteUrlInfo.mtype = paramInfo[1]; - console.log("$rootScope.siteUrlInfo.mtype" + $rootScope.siteUrlInfo.mtype); + $rootScope.siteUrlInfo.mType = paramInfo[1]; } else if (paramInfo[0].toLowerCase() == 'id') { $rootScope.siteUrlInfo.id = paramInfo[1]; - console.log("$rootScope.siteUrlInfo.id" + $rootScope.siteUrlInfo.id); } else if (paramInfo[0].toLowerCase() == 'username') { $rootScope.siteUrlInfo.userId = paramInfo[1]; - console.log("$rootScope.siteUrlInfo.username" + $rootScope.siteUrlInfo.userId); + } + else if (paramInfo[0].toLowerCase() == 'edition') { + + $rootScope.siteUrlInfo.edition = paramInfo[1]; } else if (paramInfo[0].toLowerCase() == 'accountnumber') { $rootScope.siteUrlInfo.accountNumber = paramInfo[1]; - console.log("$rootScope.siteUrlInfo.accountNumber" + $rootScope.siteUrlInfo.accountNumber); } } @@ -1485,58 +1475,91 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data } } if (isCalsCredantialForSIte == "True") { - if($rootScope.siteUrlInfo.mtype!=null && $rootScope.siteUrlInfo.mtype.toLowerCase()=='ca' && $rootScope.siteUrlInfo.id!=null && $rootScope.siteUrlInfo.id!="" && $rootScope.siteUrlInfo.userId!=null && $rootScope.siteUrlInfo.accountNumber!=null) + if($rootScope.siteUrlInfo.mType!=null && $rootScope.siteUrlInfo.mType.toLowerCase()=='ca' && $rootScope.siteUrlInfo.id!=null && $rootScope.siteUrlInfo.id!="" && $rootScope.siteUrlInfo.edition!=null && $rootScope.siteUrlInfo.accountNumber!=null) { - $rootScope.LoginDisableUI(); + $('.navbar-fixed-top').css('display','none'); var userInfo=$rootScope.userInfo;//also get session id - AuthenticationService.ByPassLoginToOpenModule($rootScope.siteUrlInfo) + $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails'); + ConfigurationService.getCofigValue() .then( - function (result) { - if(result!=null) - { - $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails'); - ConfigurationService.getCofigValue() - .then( - function (configresult) { - $rootScope.current_year = configresult.current_year; - $rootScope.aiaIdleTime = configresult.idleTime; - $rootScope.aiaIdleTimeOut = configresult.idelTimeOut; - $rootScope.aiaPingInterval = configresult.pingInterval; - $rootScope.aiaAnimationPath = configresult.serverPath; - $rootScope.MaxOneFileSize = configresult.fileSize; - $rootScope.aodDomainName = configresult.aodSiteUrl; - - userInfo.username = result.LoginId; - userInfo.password = result.Password; - userInfo.mtype = $rootScope.siteUrlInfo.mtype; - var loggedInUser = JSON.parse($scope.currentUserDetails); - if(loggedInUser!==null && loggedInUser.LoginId==result.LoginId) - { - //using old session id - userInfo.SessionId = loggedInUser.SessionId; - $rootScope.AuthenticateUser(userInfo); - } - else - { - //using new sessionid - $rootScope.AuthenticateUser(userInfo); - } - }); + function (configresult) { + $rootScope.current_year = configresult.current_year; + $rootScope.aiaIdleTime = configresult.idleTime; + $rootScope.aiaIdleTimeOut = configresult.idelTimeOut; + $rootScope.aiaPingInterval = configresult.pingInterval; + $rootScope.aiaAnimationPath = configresult.serverPath; + $rootScope.MaxOneFileSize = configresult.fileSize; + $rootScope.aodDomainName = configresult.aodSiteUrl; + + userInfo.accountNumber = $rootScope.siteUrlInfo.accountNumber; + userInfo.edition = $rootScope.siteUrlInfo.edition; + userInfo.mType = $rootScope.siteUrlInfo.mType; + + var loggedInUser = JSON.parse($scope.currentUserDetails); + //check already login by account number bcz no login id for site login + //maintain user session by licenseid of site login + if(loggedInUser!==null && loggedInUser.AccountNumber== userInfo.accountNumber) + { + //using old session id + userInfo.SessionId = loggedInUser.SessionId; + $rootScope.AuthenticateUrlLogin(userInfo); + } + else + { + //using new sessionid + $rootScope.AuthenticateUrlLogin(userInfo); + } + }); + //comment below code + // AuthenticationService.ByPassLoginToOpenModule($rootScope.siteUrlInfo) + // .then( + // function (result) { + // if(result!=null) + // { + // $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails'); + // ConfigurationService.getCofigValue() + // .then( + // function (configresult) { + // $rootScope.current_year = configresult.current_year; + // $rootScope.aiaIdleTime = configresult.idleTime; + // $rootScope.aiaIdleTimeOut = configresult.idelTimeOut; + // $rootScope.aiaPingInterval = configresult.pingInterval; + // $rootScope.aiaAnimationPath = configresult.serverPath; + // $rootScope.MaxOneFileSize = configresult.fileSize; + // $rootScope.aodDomainName = configresult.aodSiteUrl; + + // userInfo.username = result.LoginId; + // userInfo.password = result.Password; + // userInfo.mtype = $rootScope.siteUrlInfo.mtype; + // var loggedInUser = JSON.parse($scope.currentUserDetails); + // if(loggedInUser!==null && loggedInUser.LoginId==result.LoginId) + // { + // //using old session id + // userInfo.SessionId = loggedInUser.SessionId; + // $rootScope.AuthenticateUser(userInfo); + // } + // else + // { + // //using new sessionid + // $rootScope.AuthenticateUser(userInfo); + // } + // }); - } + // } - }), - function (error) { - console.log(' Error in bypass login = ' + error.statusText); - $rootScope.isVisibleLogin = true; - $rootScope.LoginEnableUI(); - $('#errorMessage').text(error); - $("#messageModal").modal('show'); - } + // }), + // function (error) { + // console.log(' Error in bypass login = ' + error.statusText); + // $rootScope.isVisibleLogin = true; + // $rootScope.LoginEnableUI(); + // $('#errorMessage').text(error); + // $("#messageModal").modal('show'); + // } } else { + $rootScope.LoginEnableUI(); console.log(' invalid detail in bypass login'); $rootScope.isVisibleLogin = true; $('#errorMessage').text("authentication is not allowed due to invalid details format.\nPlease pass the correct details again!"); @@ -1544,11 +1567,8 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data } } - else { - - console.log($rootScope.siteUrlInfo); - - $rootScope.LoginDisableUI(); + else + { $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails'); var sitedetail=$rootScope.siteUrlInfo; ConfigurationService.getCofigValue() @@ -1862,7 +1882,145 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data $rootScope.loadUserSession(); $rootScope.LoginEnableUI(); + } + + } + } + + }, + + function (error) { + + console.log(' Error in authentication = ' + error.statusText); + $rootScope.LoginEnableUI(); + $rootScope.isVisibleLogin = true; + $('#errorMessage').text(error); + $("#messageModal").modal('show'); + + } + ) + + } + + $rootScope.AuthenticateUrlLogin = function (urlInfo) { + $rootScope.LoginDisableUI(); + AuthenticationService.validateUrlLogin(urlInfo) + .then( + function (result) { + if (result != null) + { + if (result == LoginConstants.INVALID_CLIENT) { + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(LoginConstants.INVALID_CLIENT); + $("#messageModal").modal('show'); + } + else if (result == LoginConstants.MSG_NOT_AUTHORIZE_SITE_USER) { + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(LoginConstants.MSG_NOT_AUTHORIZE_SITE_USER); + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_ACCOUNT_NUMBER_NOT_NULL) { + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(LoginMessageConstants.E_ACCOUNT_NUMBER_NOT_NULL); + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_EDITION_ID_NOT_NULL) { + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(LoginMessageConstants.E_EDITION_ID_NOT_NULL); + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_EDITION_NOT_LINKED_WITH_SITE) { + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(LoginMessageConstants.E_EDITION_NOT_LINKED_WITH_SITE); + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.LICENSE_INACTIVE) { + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(LoginMessageConstants.LICENSE_INACTIVE_MESSAGE); + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.SITELICENSE_EXPIRED) { + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.'); + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.SITELICENSE_NOTSTARTED) { + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(LoginMessageConstants.SUBSCRIPTION_NOT_START_MESSAGE + result.SubscriptionStartDate + '.'); + $("#messageModal").modal('show'); + } + else + { + // update result with session detail + result.aiaIdleTime=$rootScope.aiaIdleTime; + result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut; + result.aiaPingInterval=$rootScope.aiaPingInterval; + result.SessionId=urlInfo.SessionId; + if(urlInfo.mType!=undefined) + { + //for CA bypass login + result.mType=urlInfo.mType; + } + + //display user name + $rootScope.userName=result.FirstName+" "+result.LastName; + if (typeof result.FirstName != undefined || result.FirstName != "" || result.FirstName != null) { + + // birendra// initialize exp img detail object + $rootScope.initializeUserForExportImage(result.Id); + + if (result.LicenseInfo != null ) { + $("#modestyDiv").css("pointer-events", "none"); + $("#modestyDiv").css("opacity", 0.5); + $("#modestyDiv").find("*").prop('disabled', true); + + $rootScope.userData = result; + $rootScope.userModules = result.Modules; + + //1. set haveRoleAdmin = false because LicenseInfo is not null + $rootScope.haveRoleAdmin = false; + + //2. + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + + //5. + sessionStorage.setItem("loginSession", "true"); + $rootScope.isVisibleLogin = false; + + $location.path('/'); + $timeout(function () { + $rootScope.LoginEnableUI(); + $scope.RedirectToModule(); + + }, 100); + + } + else + { + if ($('#dvTerms').length > 0) { + $('#dvTerms').html(result.TermsAndConditionsText); + } + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#dvTermCondition').fadeIn(); + $rootScope.userData = result; + $rootScope.haveRoleAdmin = false; + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + $location.path('/'); } + + $rootScope.loadUserSession(); + $rootScope.LoginEnableUI(); + + } } } @@ -2067,11 +2225,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data localStorage.removeItem('loggedInUserDetails'); localStorage.clear(); $rootScope.CheckUserSession('logout'); - $timeout(function(){ - document.location = '/'; - $rootScope.isVisibleLogin = true; - },50); - + } $rootScope.LogoutUserSession = function () { $rootScope.isSessionTimeout=true; @@ -2080,7 +2234,6 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data sessionStorage.removeItem('ExitsCBFileDetail'); localStorage.clear(); document.location = '/'; - $rootScope.isVisibleLogin = true; } $rootScope.CheckUserSession = function (tagName) { @@ -2088,6 +2241,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data //console.log('user login activity tag: '+tagName); if($rootScope.userData==undefined) return; //incase site user login userid is 0 so then using license id + //use also URL login $rootScope.userStatus.userId=$rootScope.userData.Id==0?$rootScope.userData.LicenseId:$rootScope.userData.Id; $rootScope.userStatus.tagName=tagName; $rootScope.userStatus.SessionId=$rootScope.userData.SessionId; @@ -3164,11 +3318,11 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data var modulePanel = $(document).find("div[id*='ImagePanel']"); if (modulePanel != undefined && modulePanel.length>0) { //if only one module left - if(slug=='clinical-animations' && $rootScope.userData.mtype!=undefined) + if(slug=='clinical-animations' && $rootScope.userData.mType!=undefined) { - if($rootScope.userData.mtype.toLowerCase()=='ca') + if($rootScope.userData.mType.toLowerCase()=='ca') { - $rootScope.siteUrlInfo.mtype=null; + $rootScope.siteUrlInfo.mType=null; $rootScope.siteUrlInfo.id=null; $rootScope.LogoutUser(); } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js index 8841d3c..ac7a77e 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js @@ -176,6 +176,28 @@ return deferred.promise; }, + validateUrlLogin: function (urlInfo) { + var deferred = $q.defer(); + + $http.post('/API/api/UrlLogin', JSON.stringify(urlInfo), { + 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(data); + $rootScope.isVisibleLogin = true; + $rootScope.LoginEnableUI(); + $('#errorMessage').text(data); + $("#messageModal").modal('show'); + + }); + return deferred.promise; + }, SendMailToUser: function (userInfo, havePassword) { var deferred = $q.defer(); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/ca/ca-view.html b/400-SOURCECODE/AIAHTML5.Web/app/views/ca/ca-view.html index 5b7265a..17dafef 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/ca/ca-view.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/ca/ca-view.html @@ -83,7 +83,7 @@
- +
@@ -104,7 +104,7 @@
- +
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html b/400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html index e74c6f0..1ee2379 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html @@ -1,6 +1,6 @@
-
+

diff --git a/400-SOURCECODE/AIAHTML5.Web/app/widget/MainView.html b/400-SOURCECODE/AIAHTML5.Web/app/widget/MainView.html index a869593..b3c5492 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/widget/MainView.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/widget/MainView.html @@ -1,6 +1,6 @@ 
-
+
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html b/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html index b3e7414..e402021 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html @@ -1,5 +1,5 @@ -