Showing
8 changed files
400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs
... | ... | @@ -30,5 +30,7 @@ namespace AIAHTML5.API.Constants |
30 | 30 | public const string SAVE_LAB_EXERCISE_ATTEMPT = "usp_SaveLabExerciseAttempts"; |
31 | 31 | public const string GET_LAB_EXERCISE = "GetLabExcerciseByUserId"; |
32 | 32 | |
33 | + | |
34 | + public const string GET_MODESTY_FOR_THIS_LICENSE = "usp_GetModestyForThisLicense"; | |
33 | 35 | } |
34 | 36 | } |
35 | 37 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs
1 | -using Newtonsoft.Json; | |
2 | -using Newtonsoft.Json.Linq; | |
3 | -using System; | |
4 | -using System.Collections.Generic; | |
5 | -using System.Linq; | |
6 | -using System.Net; | |
7 | -using System.Net.Http; | |
8 | -using System.Web.Http; | |
9 | -using log4net; | |
10 | -using AIAHTML5.API.Constants; | |
11 | -using AIAHTML5.API.Models; | |
12 | -using System.Collections; | |
13 | - | |
14 | -using System.Data.SqlClient;namespace AIAHTML5.API.Controllers | |
15 | -{ | |
16 | - public class AuthenticateController : ApiController | |
17 | - { | |
18 | - // GET api/authenticate | |
19 | - public IEnumerable<string> Get() | |
20 | - { | |
21 | - return new string[] { "value1", "value2" }; | |
22 | - } | |
23 | - | |
24 | - // GET api/authenticate/5 | |
25 | - public string Get(int id) | |
26 | - { | |
27 | - return "value"; | |
28 | - } | |
29 | - | |
30 | - // POST api/authenticate | |
31 | - public HttpResponseMessage Post([FromBody]JObject credentials) | |
32 | - { | |
33 | - ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
34 | - logger.Debug("inside POST"); | |
35 | - | |
36 | - dynamic authenticationRepsonse; | |
37 | - DateTime blockTime; | |
38 | - bool isUserBlocked; | |
39 | - | |
40 | - try | |
41 | - { | |
42 | - | |
43 | - //01.get the user detail to autheticate the user | |
44 | - User userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); | |
45 | - | |
46 | - if (userInfo != null) | |
47 | - { | |
48 | - // 02 Check user is authenticated or not by login credential match | |
49 | - bool isUserAuthenticated = AIAHTML5.API.Models.Users.checkUserAuthenticity(credentials, userInfo); | |
50 | - | |
51 | - if (isUserAuthenticated) | |
52 | - { | |
53 | - if (userInfo.IsActive) | |
54 | - { | |
55 | - //03. check if user is blocked | |
56 | - isUserBlocked = AIAHTML5.API.Models.Users.checkUserBlockStatus(userInfo.Id, out blockTime); | |
57 | - | |
58 | - if (!isUserBlocked) | |
59 | - { | |
60 | - //04.delete past wrong login attempts of user | |
61 | - int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); | |
62 | - if (wrongAttemptDeteledCount < 0) | |
63 | - { | |
64 | - logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); | |
65 | - } | |
66 | - //05. | |
67 | - GetModulesBasedOnUserType(userInfo); | |
68 | - | |
69 | - // authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
70 | - } | |
71 | - | |
72 | - else | |
73 | - { | |
74 | - | |
75 | - //compare block time of user with current time if user is blocked | |
76 | - DateTime blockDuration = blockTime.AddDays(1); | |
77 | - var difference = DateTime.Compare(DateTime.Now, blockDuration); | |
78 | - | |
79 | - //check if credentials are valid credentials | |
80 | - //bool isCorrectLoginId, isCorrectPassword; | |
81 | - //AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, out isCorrectLoginId, out isCorrectPassword); | |
82 | - | |
83 | - if (difference >= 0) | |
84 | - { | |
85 | - //means 24 hours block time is finished | |
86 | - userInfo.IsBlocked = false; | |
87 | - | |
88 | - int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); | |
89 | - if (wrongAttemptDeteledCount < 0) | |
90 | - { | |
91 | - logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); | |
92 | - } | |
93 | - | |
94 | - //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads | |
95 | - GetModulesBasedOnUserType(userInfo); | |
96 | - | |
97 | - } | |
98 | - else | |
99 | - { | |
100 | - userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; | |
101 | - } | |
102 | - } | |
103 | - } | |
104 | - else | |
105 | - { | |
106 | - //CODE REVIW: validate that is this tarnslated by UI because we need to show message to user if he is inactive | |
107 | - userInfo.LoginFailureCauseId = ErrorHelper.E_USER_NOT_ACTIVE; | |
108 | - | |
109 | - //05.4 check the License expiration irespective of either user is active | |
110 | - //or not because on AIA, we shows the License expiration message | |
111 | - //for inactive users too | |
112 | - | |
113 | - CheckLicenseStatus(userInfo); | |
114 | - | |
115 | - } | |
116 | - } | |
117 | - | |
118 | - else | |
119 | - { | |
120 | - //this come in picture when user input wrong passowrd | |
121 | - | |
122 | - //get wrong attempt count of user | |
123 | - int previousIncorrectLoginAttempts = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id); | |
124 | - userInfo.IncorrectLoginAttemptCount = previousIncorrectLoginAttempts + 1; | |
125 | - userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH; | |
126 | - | |
127 | - //01. insert wrong attempt in dtabase | |
128 | - int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptOfUser(userInfo.Id, previousIncorrectLoginAttempts); | |
129 | - | |
130 | - if (updateCount < 0) | |
131 | - { | |
132 | - //Put the log in log file | |
133 | - logger.Fatal("Unable to Update past wrong login attempts for userId= " + userInfo.Id); | |
134 | - } | |
135 | - //else | |
136 | - //{ | |
137 | - if (userInfo.IncorrectLoginAttemptCount > 4) | |
138 | - { | |
139 | - userInfo.IsBlocked = true; | |
140 | - userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; | |
141 | - } | |
142 | - | |
143 | - | |
144 | - } | |
145 | - | |
146 | - authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
147 | - | |
148 | - } | |
149 | - | |
150 | - else | |
151 | - { | |
152 | - authenticationRepsonse = AIAConstants.USER_NOT_FOUND; | |
153 | - } | |
154 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) }; | |
155 | - } | |
156 | - catch(SqlException e){ | |
157 | - | |
158 | - logger.Fatal("SqlException occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); | |
159 | - | |
160 | - ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
161 | - string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT; | |
162 | - string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
163 | - UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); | |
164 | - | |
165 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; | |
166 | - } | |
167 | - catch (Exception e) | |
168 | - { | |
169 | - | |
170 | - logger.Fatal("Exception occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); | |
171 | - | |
172 | - ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
173 | - string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT; | |
174 | - string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
175 | - UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); | |
176 | - | |
177 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; | |
178 | - | |
179 | - } | |
180 | - | |
181 | - } | |
182 | - | |
183 | - private static void GetModulesBasedOnUserType(User userInfo) | |
184 | - { | |
185 | - //based on old .net code(AIA flex), we get modules based on licenseId if licenseid>0. | |
186 | - //we verified in database that only superadmin has no licenseid so getting all modules for supeadmin | |
187 | - int licenseId, editionId; | |
188 | - AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); | |
189 | - | |
190 | - userInfo.LicenseId = licenseId; | |
191 | - userInfo.EditionId = editionId; | |
192 | - | |
193 | - //if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN) | |
194 | - if(userInfo.LicenseId == 0) | |
195 | - { | |
196 | - userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList(); | |
197 | - | |
198 | - //Insert user login detail | |
199 | - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
200 | - } | |
201 | - else | |
202 | - { | |
203 | - CheckLicenseStatus(userInfo); | |
204 | - | |
205 | - if(!userInfo.IsSubscriptionExpired){ | |
206 | - GetModulesBasedOnLicense(userInfo,false); | |
207 | - } | |
208 | - } | |
209 | - } | |
210 | - | |
211 | - private static void CheckLicenseStatus(User userInfo) | |
212 | - { | |
213 | - //05.1 For normal user need to get the license details, get the license id for authenticated user | |
214 | - //int licenseId, editionId; | |
215 | - //AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); | |
216 | - | |
217 | - //userInfo.LicenseId = licenseId; | |
218 | - //userInfo.EditionId = editionId; | |
219 | - | |
220 | - //05.2 get license details | |
221 | - userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId); | |
222 | - | |
223 | - if (userInfo.LicenseInfo != null) | |
224 | - { | |
225 | - //05.3 get licenseSubscription details | |
226 | - userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); | |
227 | - | |
228 | - //05.4 check the License expiration irespective of either user is active or not because on AIA | |
229 | - //we shows the License expiration message for inactive users too | |
230 | - string expirationDate = null; | |
231 | - bool isLicenseExpired = false; | |
232 | - | |
233 | - if (userInfo.LicenseSubscriptions != null) | |
234 | - { | |
235 | - isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate); | |
236 | - } | |
237 | - | |
238 | - if (isLicenseExpired) | |
239 | - { | |
240 | - userInfo.IsSubscriptionExpired = isLicenseExpired; | |
241 | - userInfo.SubscriptionExpirationDate = expirationDate; | |
242 | - } | |
243 | - } | |
244 | - | |
245 | - else | |
246 | - { | |
247 | - ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
248 | - logger.Debug("userInfo.LicenseInfo is null for userInfo.LicenseId= "+userInfo.LicenseId); | |
249 | - } | |
250 | - } | |
251 | - | |
252 | - private static void GetModulesBasedOnLicense(User userInfo, bool isLicenseExpired) | |
253 | - { | |
254 | - | |
255 | - //05.6.1 | |
256 | - if (userInfo.LicenseInfo.IsActive) | |
257 | - { | |
258 | - if (!userInfo.LicenseInfo.IsTermAccepted) | |
259 | - { | |
260 | - ArrayList termsList = AIAHTML5.API.Models.Users.getTermsAndConditions(); | |
261 | - foreach (Hashtable item in termsList) | |
262 | - { | |
263 | - userInfo.TermsAndConditionsTitle = item[AIAConstants.KEY_TITLE].ToString(); | |
264 | - userInfo.TermsAndConditionsText = item[AIAConstants.KEY_CONTENT].ToString(); | |
265 | - } | |
266 | - } | |
267 | - else | |
268 | - { | |
269 | - userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); | |
270 | - | |
271 | - //Insert user login detail | |
272 | - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
273 | - } | |
274 | - } | |
275 | - else | |
276 | - { | |
277 | - userInfo.LoginFailureCauseId = ErrorHelper.E_LICENCE_IS_INACTIVE; | |
278 | - | |
279 | - } | |
280 | - } | |
281 | - | |
282 | - | |
283 | - | |
284 | - // PUT api/authenticate/5 | |
285 | - public void Put(int id, [FromBody]string value) | |
286 | - { | |
287 | - } | |
288 | - | |
289 | - // DELETE api/authenticate/5 | |
290 | - public void Delete(int id) | |
291 | - { | |
292 | - } | |
293 | - } | |
1 | +using Newtonsoft.Json; | |
2 | +using Newtonsoft.Json.Linq; | |
3 | +using System; | |
4 | +using System.Collections.Generic; | |
5 | +using System.Linq; | |
6 | +using System.Net; | |
7 | +using System.Net.Http; | |
8 | +using System.Web.Http; | |
9 | +using log4net; | |
10 | +using AIAHTML5.API.Constants; | |
11 | +using AIAHTML5.API.Models; | |
12 | +using System.Collections; | |
13 | + | |
14 | +using System.Data.SqlClient;namespace AIAHTML5.API.Controllers | |
15 | +{ | |
16 | + public class AuthenticateController : ApiController | |
17 | + { | |
18 | + // GET api/authenticate | |
19 | + public IEnumerable<string> Get() | |
20 | + { | |
21 | + return new string[] { "value1", "value2" }; | |
22 | + } | |
23 | + | |
24 | + // GET api/authenticate/5 | |
25 | + public string Get(int id) | |
26 | + { | |
27 | + return "value"; | |
28 | + } | |
29 | + | |
30 | + // POST api/authenticate | |
31 | + public HttpResponseMessage Post([FromBody]JObject credentials) | |
32 | + { | |
33 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
34 | + logger.Debug("inside POST"); | |
35 | + | |
36 | + dynamic authenticationRepsonse; | |
37 | + DateTime blockTime; | |
38 | + bool isUserBlocked; | |
39 | + | |
40 | + try | |
41 | + { | |
42 | + | |
43 | + //01.get the user detail to autheticate the user | |
44 | + User userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); | |
45 | + | |
46 | + if (userInfo != null) | |
47 | + { | |
48 | + // 02 Check user is authenticated or not by login credential match | |
49 | + bool isUserAuthenticated = AIAHTML5.API.Models.Users.checkUserAuthenticity(credentials, userInfo); | |
50 | + | |
51 | + if (isUserAuthenticated) | |
52 | + { | |
53 | + if (userInfo.IsActive) | |
54 | + { | |
55 | + //03. check if user is blocked | |
56 | + isUserBlocked = AIAHTML5.API.Models.Users.checkUserBlockStatus(userInfo.Id, out blockTime); | |
57 | + | |
58 | + if (!isUserBlocked) | |
59 | + { | |
60 | + //04.delete past wrong login attempts of user | |
61 | + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); | |
62 | + if (wrongAttemptDeteledCount < 0) | |
63 | + { | |
64 | + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); | |
65 | + } | |
66 | + //05. | |
67 | + GetModulesBasedOnUserType(userInfo); | |
68 | + | |
69 | + // authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
70 | + } | |
71 | + | |
72 | + else | |
73 | + { | |
74 | + | |
75 | + //compare block time of user with current time if user is blocked | |
76 | + DateTime blockDuration = blockTime.AddDays(1); | |
77 | + var difference = DateTime.Compare(DateTime.Now, blockDuration); | |
78 | + | |
79 | + //check if credentials are valid credentials | |
80 | + //bool isCorrectLoginId, isCorrectPassword; | |
81 | + //AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, out isCorrectLoginId, out isCorrectPassword); | |
82 | + | |
83 | + if (difference >= 0) | |
84 | + { | |
85 | + //means 24 hours block time is finished | |
86 | + userInfo.IsBlocked = false; | |
87 | + | |
88 | + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); | |
89 | + if (wrongAttemptDeteledCount < 0) | |
90 | + { | |
91 | + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); | |
92 | + } | |
93 | + | |
94 | + //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads | |
95 | + GetModulesBasedOnUserType(userInfo); | |
96 | + | |
97 | + } | |
98 | + else | |
99 | + { | |
100 | + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; | |
101 | + } | |
102 | + } | |
103 | + } | |
104 | + else | |
105 | + { | |
106 | + //CODE REVIW: validate that is this tarnslated by UI because we need to show message to user if he is inactive | |
107 | + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_NOT_ACTIVE; | |
108 | + | |
109 | + //05.4 check the License expiration irespective of either user is active | |
110 | + //or not because on AIA, we shows the License expiration message | |
111 | + //for inactive users too | |
112 | + | |
113 | + CheckLicenseStatus(userInfo); | |
114 | + | |
115 | + } | |
116 | + } | |
117 | + | |
118 | + else | |
119 | + { | |
120 | + //this come in picture when user input wrong passowrd | |
121 | + | |
122 | + //get wrong attempt count of user | |
123 | + int previousIncorrectLoginAttempts = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id); | |
124 | + userInfo.IncorrectLoginAttemptCount = previousIncorrectLoginAttempts + 1; | |
125 | + userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH; | |
126 | + | |
127 | + //01. insert wrong attempt in dtabase | |
128 | + int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptOfUser(userInfo.Id, previousIncorrectLoginAttempts); | |
129 | + | |
130 | + if (updateCount < 0) | |
131 | + { | |
132 | + //Put the log in log file | |
133 | + logger.Fatal("Unable to Update past wrong login attempts for userId= " + userInfo.Id); | |
134 | + } | |
135 | + //else | |
136 | + //{ | |
137 | + if (userInfo.IncorrectLoginAttemptCount > 4) | |
138 | + { | |
139 | + userInfo.IsBlocked = true; | |
140 | + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; | |
141 | + } | |
142 | + | |
143 | + | |
144 | + } | |
145 | + | |
146 | + authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
147 | + | |
148 | + } | |
149 | + | |
150 | + else | |
151 | + { | |
152 | + authenticationRepsonse = AIAConstants.USER_NOT_FOUND; | |
153 | + } | |
154 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) }; | |
155 | + } | |
156 | + catch(SqlException e){ | |
157 | + | |
158 | + logger.Fatal("SqlException occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); | |
159 | + | |
160 | + ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
161 | + string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT; | |
162 | + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
163 | + UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); | |
164 | + | |
165 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; | |
166 | + } | |
167 | + catch (Exception e) | |
168 | + { | |
169 | + | |
170 | + logger.Fatal("Exception occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); | |
171 | + | |
172 | + ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
173 | + string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT; | |
174 | + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
175 | + UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); | |
176 | + | |
177 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; | |
178 | + | |
179 | + } | |
180 | + | |
181 | + } | |
182 | + | |
183 | + private static void GetModulesBasedOnUserType(User userInfo) | |
184 | + { | |
185 | + //based on old .net code(AIA flex), we get modules based on licenseId if licenseid>0. | |
186 | + //we verified in database that only superadmin has no licenseid so getting all modules for supeadmin | |
187 | + int licenseId, editionId; | |
188 | + AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); | |
189 | + | |
190 | + userInfo.LicenseId = licenseId; | |
191 | + userInfo.EditionId = editionId; | |
192 | + | |
193 | + //if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN) | |
194 | + if(userInfo.LicenseId == 0) | |
195 | + { | |
196 | + userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList(); | |
197 | + | |
198 | + //Insert user login detail | |
199 | + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
200 | + } | |
201 | + else | |
202 | + { | |
203 | + CheckLicenseStatus(userInfo); | |
204 | + | |
205 | + if(!userInfo.IsSubscriptionExpired){ | |
206 | + GetModulesBasedOnLicense(userInfo,false); | |
207 | + } | |
208 | + } | |
209 | + } | |
210 | + | |
211 | + private static void CheckLicenseStatus(User userInfo) | |
212 | + { | |
213 | + //05.1 For normal user need to get the license details, get the license id for authenticated user | |
214 | + //int licenseId, editionId; | |
215 | + //AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); | |
216 | + | |
217 | + //userInfo.LicenseId = licenseId; | |
218 | + //userInfo.EditionId = editionId; | |
219 | + | |
220 | + //05.2 get license details | |
221 | + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId); | |
222 | + | |
223 | + if (userInfo.LicenseInfo != null) | |
224 | + { | |
225 | + //05.3 get licenseSubscription details | |
226 | + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); | |
227 | + | |
228 | + | |
229 | + | |
230 | + //05.4 check the License expiration irespective of either user is active or not because on AIA | |
231 | + //we shows the License expiration message for inactive users too | |
232 | + string expirationDate = null; | |
233 | + bool isLicenseExpired = false; | |
234 | + | |
235 | + if (userInfo.LicenseSubscriptions != null) | |
236 | + { | |
237 | + isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate); | |
238 | + } | |
239 | + | |
240 | + if (isLicenseExpired) | |
241 | + { | |
242 | + userInfo.IsSubscriptionExpired = isLicenseExpired; | |
243 | + userInfo.SubscriptionExpirationDate = expirationDate; | |
244 | + } | |
245 | + else | |
246 | + { | |
247 | + //check Modesty settings for this license | |
248 | + | |
249 | + userInfo.IsModestyOn = AIAHTML5.API.Models.Users.IsModestyActiveForThisLicense(userInfo.LicenseId); | |
250 | + | |
251 | + | |
252 | + } | |
253 | + } | |
254 | + | |
255 | + else | |
256 | + { | |
257 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
258 | + logger.Debug("userInfo.LicenseInfo is null for userInfo.LicenseId= "+userInfo.LicenseId); | |
259 | + } | |
260 | + } | |
261 | + | |
262 | + private static void GetModulesBasedOnLicense(User userInfo, bool isLicenseExpired) | |
263 | + { | |
264 | + | |
265 | + //05.6.1 | |
266 | + if (userInfo.LicenseInfo.IsActive) | |
267 | + { | |
268 | + if (!userInfo.LicenseInfo.IsTermAccepted) | |
269 | + { | |
270 | + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsAndConditions(); | |
271 | + foreach (Hashtable item in termsList) | |
272 | + { | |
273 | + userInfo.TermsAndConditionsTitle = item[AIAConstants.KEY_TITLE].ToString(); | |
274 | + userInfo.TermsAndConditionsText = item[AIAConstants.KEY_CONTENT].ToString(); | |
275 | + } | |
276 | + } | |
277 | + else | |
278 | + { | |
279 | + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); | |
280 | + | |
281 | + //Insert user login detail | |
282 | + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
283 | + } | |
284 | + } | |
285 | + else | |
286 | + { | |
287 | + userInfo.LoginFailureCauseId = ErrorHelper.E_LICENCE_IS_INACTIVE; | |
288 | + | |
289 | + } | |
290 | + } | |
291 | + | |
292 | + | |
293 | + | |
294 | + // PUT api/authenticate/5 | |
295 | + public void Put(int id, [FromBody]string value) | |
296 | + { | |
297 | + } | |
298 | + | |
299 | + // DELETE api/authenticate/5 | |
300 | + public void Delete(int id) | |
301 | + { | |
302 | + } | |
303 | + } | |
294 | 304 | } |
295 | 305 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
... | ... | @@ -783,6 +783,42 @@ namespace AIAHTML5.API.Models |
783 | 783 | return blockedUser; |
784 | 784 | } |
785 | 785 | |
786 | + internal Boolean GetModestyInfo(int LicenseId) | |
787 | + { | |
788 | + logger.Debug(" inside GetModestyInfo for licenseId= " + LicenseId); | |
789 | + | |
790 | + Boolean isModestyOn = false; | |
791 | + | |
792 | + DataTable dt = null; | |
793 | + | |
794 | + SqlConnection conn = new SqlConnection(dbConnectionString); | |
795 | + SqlCommand cmd = new SqlCommand(); | |
796 | + cmd.Connection = conn; | |
797 | + cmd.CommandText = DBConstants.GET_MODESTY_FOR_THIS_LICENSE; | |
798 | + cmd.CommandType = CommandType.StoredProcedure; | |
799 | + cmd.Parameters.AddWithValue("@licenseId", LicenseId); | |
800 | + SqlDataAdapter da = new SqlDataAdapter(); | |
801 | + da.SelectCommand = cmd; | |
802 | + dt = new DataTable(); | |
803 | + da.Fill(dt); | |
804 | + | |
805 | + if (dt != null && dt.Rows.Count > 0) | |
806 | + { | |
807 | + string IsModesty = dt.Rows[0]["IsModesty"].ToString(); | |
808 | + if(IsModesty== "True") | |
809 | + { | |
810 | + isModestyOn = true; | |
811 | + } | |
812 | + else | |
813 | + { | |
814 | + isModestyOn = false; | |
815 | + } | |
816 | + } | |
817 | + | |
818 | + | |
819 | + return isModestyOn; | |
820 | + } | |
821 | + | |
786 | 822 | protected ArrayList GetBlockedUsersByUserType(int userTypeId) |
787 | 823 | { |
788 | 824 | logger.Debug(" inside GetBlockedUsersByUserType for UserTypeId= " + userTypeId); | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/User.cs
... | ... | @@ -30,6 +30,8 @@ namespace AIAHTML5.API.Models |
30 | 30 | public int LicenseId { get; set; } |
31 | 31 | public int EditionId { get; set; } |
32 | 32 | public Int16 LoginFailureCauseId { get; set; } |
33 | + | |
34 | + public bool IsModestyOn { get; set; } | |
33 | 35 | |
34 | 36 | public ArrayList Modules { get; set; } |
35 | 37 | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... | ... | @@ -354,5 +354,12 @@ namespace AIAHTML5.API.Models |
354 | 354 | |
355 | 355 | return isUserBlocked; |
356 | 356 | } |
357 | + | |
358 | + internal static Boolean IsModestyActiveForThisLicense(int LicenseId) | |
359 | + { | |
360 | + DBModel objModel = new DBModel(); | |
361 | + bool IsModestyOn = objModel.GetModestyInfo(LicenseId); | |
362 | + return IsModestyOn; | |
363 | + } | |
357 | 364 | } |
358 | 365 | } |
359 | 366 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj
... | ... | @@ -70,6 +70,7 @@ |
70 | 70 | <Content Include="app\views\ADAMImg\ADAMImg-view.html" /> |
71 | 71 | <Content Include="app\views\atlas-anatomy-detail.html" /> |
72 | 72 | <Content Include="app\views\ca\clinical-animations-detail.html" /> |
73 | + <Content Include="app\views\CBuild\AdobePlayerDownloadLink.html" /> | |
73 | 74 | <Content Include="app\views\ci\clinical-illustrations-detail.html" /> |
74 | 75 | <Content Include="app\views\da\da-view.html" /> |
75 | 76 | <Content Include="app\views\Home\printPreview.html" /> | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... | ... | @@ -200,7 +200,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A |
200 | 200 | .then( |
201 | 201 | |
202 | 202 | function (result) { |
203 | - | |
203 | + console.log(result); | |
204 | 204 | if (result == LoginConstants.USER_NOT_FOUND) { |
205 | 205 | $rootScope.isVisibleLogin = true; |
206 | 206 | // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT); |
... | ... | @@ -208,6 +208,41 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A |
208 | 208 | $("#messageModal").modal('show'); |
209 | 209 | } |
210 | 210 | else { |
211 | + //code for modesty setting | |
212 | + if (result.LicenseInfo != null) { | |
213 | + if (result.IsModestyOn) { | |
214 | + $rootScope.isModestyOn = true; | |
215 | + $rootScope.isModestyOff = false; | |
216 | + localStorage.setItem("globalModesty", "Y"); | |
217 | + $rootScope.formsetting = { | |
218 | + ethnicity: null, | |
219 | + modesty: "Y" | |
220 | + } | |
221 | + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) | |
222 | + } | |
223 | + else { | |
224 | + $rootScope.isModestyOn = false; | |
225 | + $rootScope.isModestyOff = true; | |
226 | + localStorage.setItem("globalModesty", "N"); | |
227 | + $rootScope.formsetting = { | |
228 | + ethnicity: null, | |
229 | + modesty: "N" | |
230 | + } | |
231 | + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) | |
232 | + } | |
233 | + } | |
234 | + else | |
235 | + { | |
236 | + $rootScope.isModestyOn = true; | |
237 | + $rootScope.isModestyOff = false; | |
238 | + localStorage.setItem("globalModesty", "Y"); | |
239 | + $rootScope.formsetting = { | |
240 | + ethnicity: null, | |
241 | + modesty: "Y" | |
242 | + } | |
243 | + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) | |
244 | + } | |
245 | + //code for modesty setting | |
211 | 246 | |
212 | 247 | if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) { |
213 | 248 | |
... | ... | @@ -4727,7 +4762,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A |
4727 | 4762 | }; |
4728 | 4763 | |
4729 | 4764 | $rootScope.loadsettings = function () { |
4730 | - | |
4765 | + | |
4731 | 4766 | //1. For now we are by default opening DA settings tab |
4732 | 4767 | $rootScope.SettingsTab = 3; |
4733 | 4768 | |
... | ... | @@ -4758,7 +4793,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A |
4758 | 4793 | }; |
4759 | 4794 | |
4760 | 4795 | $rootScope.setModestySettings = function (currentmodsetting) { |
4761 | - | |
4796 | + | |
4762 | 4797 | if (currentmodsetting == 'Y') { |
4763 | 4798 | $rootScope.isModestyOn = true; |
4764 | 4799 | $rootScope.isModestyOff = false; |
... | ... | @@ -4814,6 +4849,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A |
4814 | 4849 | } |
4815 | 4850 | |
4816 | 4851 | $rootScope.ChangeModesty = function (formsetting, modestyValue) { |
4852 | + | |
4817 | 4853 | formsetting.modesty = modestyValue; |
4818 | 4854 | $rootScope.setModestySettings(formsetting.modesty); |
4819 | 4855 | |
... | ... | @@ -4836,7 +4872,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A |
4836 | 4872 | } |
4837 | 4873 | |
4838 | 4874 | $rootScope.UpdateAndCloseSetting = function (setting) { |
4839 | - | |
4875 | + | |
4840 | 4876 | $rootScope.UpdateSetting(setting); |
4841 | 4877 | if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") { |
4842 | 4878 | $rootScope.loadSearchData(); |
... | ... | @@ -4856,6 +4892,8 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A |
4856 | 4892 | }; |
4857 | 4893 | |
4858 | 4894 | |
4895 | + | |
4896 | + | |
4859 | 4897 | |
4860 | 4898 | $rootScope.deSelectLanguageOptions = function () { |
4861 | 4899 | |
... | ... | @@ -4943,7 +4981,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A |
4943 | 4981 | |
4944 | 4982 | |
4945 | 4983 | $rootScope.UpdateSetting = function (setting) { |
4946 | - | |
4984 | + | |
4947 | 4985 | $rootScope.isApplyBtnClicked = true; |
4948 | 4986 | var isReloadingViewRequired = false; |
4949 | 4987 | //1. | ... | ... |
400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/AdobePlayerDownloadLink.html
0 → 100644
1 | +<!doctype html> | |
2 | +<html lang="en"> | |
3 | + <head> | |
4 | + <!-- Required meta tags --> | |
5 | + <meta charset="utf-8"> | |
6 | + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
7 | + <title>Ebix</title> | |
8 | + </head> | |
9 | + <style> | |
10 | + | |
11 | +.wrapper .container-fluid{width:100%;background:#818d43;} | |
12 | +.wrapper .container { | |
13 | + width: 980px; | |
14 | + margin: 0 auto; | |
15 | +} | |
16 | +.wrapper h3{background:#818d43; margin:0; padding:20px 0; color:#fff; font-size:20px;} | |
17 | +dl dt{font-size:18px; font-weight:bold; padding:10px 0 5px 0;} | |
18 | +dl dd{font-size:16px; font-weight:500; line-height:28px; padding:5px 0; margin-left:0;} | |
19 | +dl dd a{color:#084d6c;} | |
20 | +</style> | |
21 | + <body style="font-family:arial; margin:0;"> | |
22 | + <div class="wrapper"> | |
23 | + <div class="container-fluid"> | |
24 | + <div class="container"> | |
25 | + <h3>CURRICULUM BUILDER</h3> | |
26 | + </div> | |
27 | + </div> | |
28 | +<div class="container"> | |
29 | + <div style="font-size:16px; margin-top:40px; margin-bottom:40px; line-height:26px;"> | |
30 | + Adobe Flash will still be needed to access Curriculum Builder module for now. | |
31 | + In order to utilize this aspect of AIA you will need to enable Adobe Flash Player to be used within your browser. | |
32 | + Below please find the appropriate browser that you are using and follow the | |
33 | + instructions to enable Flash Player and return back to | |
34 | + the Curriculum Builder module to access the module. | |
35 | + </div> | |
36 | + <dl> | |
37 | + <dt>Chrome –</dt> | |
38 | + <dd><a href="https://support.google.com/chrome/answer/6258784">https://support.google.com/chrome/answer/6258784</a></dd> | |
39 | + <dt>FireFox –</dt> | |
40 | + <dd><a href="https://support.mozilla.org/en-US/kb/set-adobe-flash-click-play-firefox">https://support.mozilla.org/en-US/kb/set-adobe-flash-click-play-firefox</a></dd> | |
41 | + <dt>Safari –</dt> | |
42 | + <dd><a href="https://helpx.adobe.com/flash-player/kb/enabling-flash-player-safari.html">https://helpx.adobe.com/flash-player/kb/enabling-flash-player-safari.html</a></dd> | |
43 | + <dt>Edge –</dt> | |
44 | + <dd><a href="https://helpx.adobe.com/flash-player/kb/flash-player-issues-windows-10-edge.html">https://helpx.adobe.com/flash-player/kb/flash-player-issues-windows-10-edge.html</a></dd> | |
45 | + <dt>Internet Explorer –</dt> | |
46 | + <dd><a href="https://helpx.adobe.com/flash-player/kb/flash-player-issues-windows-10-ie.html">https://helpx.adobe.com/flash-player/kb/flash-player-issues-windows-10-ie.html</a></dd> | |
47 | + </dl> | |
48 | +</div> | |
49 | +</div> | |
50 | +</body> | |
51 | +</html> | |
0 | 52 | \ No newline at end of file | ... | ... |