Commit 26cb5ca99afd14642f646609097f7ce0ccee3192
1 parent
821ed448
login code is implemented
Showing
6 changed files
with
164 additions
and
283 deletions
150-DOCUMENTATION/002-DBScripts/GetTermsOfServiceText.sql renamed to 150-DOCUMENTATION/002-DBScripts/GetTermsAndConditions.sql
... | ... | @@ -18,7 +18,7 @@ GO |
18 | 18 | -- Create date: <Create Date,,> |
19 | 19 | -- Description: <Description,,> |
20 | 20 | -- ============================================= |
21 | -CREATE PROCEDURE GetTermsOfServiceText | |
21 | +CREATE PROCEDURE GetTermsAndConditions | |
22 | 22 | -- Add the parameters for the stored procedure here |
23 | 23 | |
24 | 24 | AS | ... | ... |
400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs
... | ... | @@ -16,8 +16,8 @@ namespace AIAHTML5.API.Constants |
16 | 16 | public const string UPDATE_USER_PASSWORD = "UpdateUserPassword"; |
17 | 17 | public const string GET_SUBSCRIPTION_DETAILS_BY_LICENSE_ID = "GetSubscriptionDetailsByLicenseId"; |
18 | 18 | public const string GET_LICENSE_DETAILS_BY_ID = "GetLicenseDetailsById"; |
19 | - public const string UPDATE_LICENSE_TERM_STATUS = "UpdateLicenseTermAcceptedStatus"; | |
20 | - public const string GET_TERMS_OF_SERVICE_TEXT = "GetTermsOfServiceText"; | |
19 | + public const string UPDATE_LICENSE_TERM_STATUS = "UpdateLicenseTermAcceptedStatus"; | |
20 | + public const string GET_TERMS_AND_CONDITIONS = "GetTermsAndConditions"; | |
21 | 21 | public const string INSERT_LOGIN_DETAIL = "InsertLoginDetail"; |
22 | 22 | public const string INSERT_INCORRECT_LOGIN_ATTEMPTS = "InsertIncorrectLoginAttempt"; |
23 | 23 | public const string GET_INCORRECT_LOGIN_ATTEMPTS = "GetIncorrectLoginAttempt"; | ... | ... |
400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs
... | ... | @@ -34,21 +34,20 @@ namespace AIAHTML5.API.Controllers |
34 | 34 | logger.Debug("inside POST"); |
35 | 35 | |
36 | 36 | dynamic authenticationRepsonse; |
37 | + DateTime blockTime; | |
38 | + bool isUserBlocked; | |
37 | 39 | |
38 | 40 | try |
39 | 41 | { |
40 | 42 | |
41 | - //01.get the user detail to autheticate user | |
42 | - User userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); | |
43 | + //01.get the user detail to autheticate the user | |
44 | + User userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); | |
43 | 45 | |
44 | 46 | if (userInfo!= null) |
45 | 47 | { |
46 | - // Check user is authenticated or not by login credential math | |
48 | + // Check user is authenticated or not by login credential match | |
47 | 49 | bool isUserAuthenticated = AIAHTML5.API.Models.Users.checkUserAuthenticity(credentials, userInfo); |
48 | 50 | |
49 | - DateTime blockTime; | |
50 | - bool isUserBlocked; | |
51 | - | |
52 | 51 | if (isUserAuthenticated) |
53 | 52 | { |
54 | 53 | |
... | ... | @@ -56,7 +55,8 @@ namespace AIAHTML5.API.Controllers |
56 | 55 | userInfo.IsCorrectPassword = true; |
57 | 56 | |
58 | 57 | //02. check if user is blocked |
59 | - | |
58 | + if(userInfo.IsActive){ | |
59 | + | |
60 | 60 | isUserBlocked = AIAHTML5.API.Models.Users.checkUserBlockStatus(userInfo.Id, out blockTime); |
61 | 61 | |
62 | 62 | |
... | ... | @@ -70,86 +70,11 @@ namespace AIAHTML5.API.Controllers |
70 | 70 | } |
71 | 71 | |
72 | 72 | //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads |
73 | - if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN || userInfo.UserType == AIAHTML5.API.Models.User.GENERAL_ADMIN) | |
74 | - { | |
75 | - userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList(); | |
76 | - | |
77 | - //Insert user login detail | |
78 | - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
79 | - } | |
80 | - else | |
81 | - { | |
82 | - //05.1 For normal user need to get the license details, get the license id for authenticated user | |
83 | - int licenseId, editionId; | |
84 | - AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); | |
85 | - | |
86 | - userInfo.LicenseId = licenseId; | |
87 | - userInfo.EditionId = editionId; | |
88 | - | |
89 | - //05.2 Check user is active or not | |
90 | - | |
91 | - | |
92 | - //05.3 get license details | |
93 | - userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId); | |
94 | - | |
95 | - if (userInfo.LicenseInfo.Id > 0) | |
96 | - { | |
97 | - //05.4 get licenseSubscription details | |
98 | - userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); | |
99 | - | |
100 | - //05.5 check the License expiration irespective of either user is active or not because on AIA | |
101 | - //we shows the License expiration message for inactive users too | |
102 | - string expirationDate = null; | |
103 | - bool isLicenseExpired = false; | |
104 | - | |
105 | - if (userInfo.LicenseSubscriptions.Id > 0) | |
106 | - { | |
107 | - isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate); | |
108 | - } | |
109 | - | |
110 | - // send message to the UI for license expiration | |
111 | - //05.6 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired] | |
112 | - if (isLicenseExpired) | |
113 | - { | |
114 | - userInfo.IsSubscriptionExpired = isLicenseExpired; | |
115 | - userInfo.SubscriptionExpirationDate = expirationDate; | |
116 | - } | |
117 | - else | |
118 | - { | |
119 | - //05.6.1 | |
120 | - if (userInfo.LicenseInfo.IsActive) | |
121 | - { | |
122 | - if (!userInfo.LicenseInfo.IsTermAccepted) | |
123 | - { | |
124 | - ArrayList termsList = AIAHTML5.API.Models.Users.getTermsOfServiceText(); | |
125 | - foreach (Hashtable item in termsList) | |
126 | - { | |
127 | - userInfo.TermsOfServiceTitle = item[AIAConstants.KEY_TITLE].ToString(); | |
128 | - userInfo.TermsOfServiceText = item[AIAConstants.KEY_CONTENT].ToString(); | |
129 | - } | |
130 | - } | |
131 | - else | |
132 | - { | |
133 | - userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); | |
134 | - | |
135 | - //Insert user login detail | |
136 | - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
137 | - } | |
138 | - } | |
139 | - else | |
140 | - { | |
141 | - //05.6.1.1 | |
142 | - // return message of license inactive | |
143 | - // property value assigned. Separate return statement not required | |
144 | - | |
145 | - } | |
146 | - } | |
147 | - } | |
148 | - } | |
73 | + GetModulesBasedOnUserType(userInfo); | |
149 | 74 | |
150 | - authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
151 | - } | |
75 | + // authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
152 | 76 | } |
77 | + | |
153 | 78 | else |
154 | 79 | { |
155 | 80 | //compare block time of user with current time if user is blocked |
... | ... | @@ -157,17 +82,13 @@ namespace AIAHTML5.API.Controllers |
157 | 82 | var difference = DateTime.Compare(DateTime.Now, blockDuration); |
158 | 83 | |
159 | 84 | //check if credentials are valid credentials |
160 | - bool isCorrectLoginId, isCorrectPassword; | |
161 | - AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, out isCorrectLoginId, out isCorrectPassword); | |
162 | - | |
163 | - if (isUserBlocked) | |
164 | - { | |
85 | + //bool isCorrectLoginId, isCorrectPassword; | |
86 | + //AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, out isCorrectLoginId, out isCorrectPassword); | |
87 | + | |
165 | 88 | if (difference >= 0) |
166 | 89 | { |
167 | - if (isCorrectPassword) | |
168 | - { | |
169 | - userInfo.IsBlocked = false; | |
170 | - userInfo.IsCorrectPassword = true; | |
90 | + //means 24 hours block time is finished | |
91 | + userInfo.IsBlocked = false; | |
171 | 92 | |
172 | 93 | int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); |
173 | 94 | if (wrongAttemptDeteledCount < 0) |
... | ... | @@ -176,163 +97,53 @@ namespace AIAHTML5.API.Controllers |
176 | 97 | } |
177 | 98 | |
178 | 99 | //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads |
179 | - | |
180 | - if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN || userInfo.UserType == AIAHTML5.API.Models.User.GENERAL_ADMIN) | |
181 | - { | |
182 | - userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList(); | |
183 | - | |
184 | - //Insert user login detail | |
185 | - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
186 | - } | |
187 | - else | |
188 | - { | |
189 | - //05.1 For normal user need to get the license details, get the license id for aUTHENTICATED USER | |
190 | - int licenseId, editionId; | |
191 | - AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); | |
192 | - | |
193 | - userInfo.LicenseId = licenseId; | |
194 | - userInfo.EditionId = editionId; | |
195 | - | |
196 | - //05.2 Check user is active or not | |
197 | - | |
198 | - | |
199 | - //05.3 get license/ licenseSubscription details | |
200 | - userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId); | |
201 | - | |
202 | - if (userInfo.LicenseInfo.Id > 0) | |
203 | - { | |
204 | - //05.4 | |
205 | - userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); | |
206 | - | |
207 | - //05.5 check the License expiration irespective of either user is active or not because on AIA | |
208 | - //we shows the License expiration message for inactive users too | |
209 | - string expirationDate = null; | |
210 | - bool isLicenseExpired = false; | |
211 | - | |
212 | - if (userInfo.LicenseSubscriptions.Id > 0) | |
213 | - { | |
214 | - isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate); | |
215 | - } | |
216 | - // send message to the UI for license expiration | |
217 | - //05.6 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired] | |
218 | - if (isLicenseExpired) | |
219 | - { | |
220 | - userInfo.IsSubscriptionExpired = isLicenseExpired; | |
221 | - userInfo.SubscriptionExpirationDate = expirationDate; | |
222 | - } | |
223 | - else | |
224 | - { | |
225 | - //05.6.1 | |
226 | - if (userInfo.LicenseInfo.IsActive) | |
227 | - { | |
228 | - if (!userInfo.LicenseInfo.IsTermAccepted) | |
229 | - { | |
230 | - ArrayList termsList = AIAHTML5.API.Models.Users.getTermsOfServiceText(); | |
231 | - foreach (Hashtable item in termsList) | |
232 | - { | |
233 | - userInfo.TermsOfServiceTitle = item[AIAConstants.KEY_TITLE].ToString(); | |
234 | - userInfo.TermsOfServiceText = item[AIAConstants.KEY_CONTENT].ToString(); | |
235 | - } | |
236 | - } | |
237 | - else | |
238 | - { | |
239 | - userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); | |
240 | - | |
241 | - //Insert user login detail | |
242 | - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
243 | - } | |
244 | - } | |
245 | - else | |
246 | - { | |
247 | - //05.6.1.1 | |
248 | - // return message of license inactive | |
249 | - // property value assigned. Separate return statement not required | |
250 | - | |
251 | - } | |
252 | - } | |
253 | - } | |
254 | - } | |
255 | - } | |
256 | - else | |
257 | - { | |
258 | - int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); | |
259 | - if (wrongAttemptDeteledCount < 0) | |
260 | - { | |
261 | - logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); | |
262 | - } | |
263 | - | |
264 | - // send message back to th UI that password is incorrect | |
265 | - userInfo.IsCorrectPassword = false; | |
266 | - | |
267 | - //get wrong attempt count of user | |
268 | - userInfo.IncorrectLoginAttemptCount = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id) + 1; | |
269 | - userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH; | |
270 | - | |
271 | - //01. insert wrong attempt in dtabase | |
272 | - int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptofUser(userInfo.Id); | |
273 | - | |
274 | - if (updateCount < 0) | |
275 | - { | |
276 | - //Put the log in log file | |
277 | - logger.Fatal("Unable to Update past wrong login attempts for userId= " + userInfo.Id); | |
278 | - } | |
279 | - else | |
280 | - { | |
281 | - if (userInfo.IncorrectLoginAttemptCount > 4) | |
282 | - { | |
283 | - userInfo.IsBlocked = true; | |
284 | - userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; | |
285 | - } | |
286 | - } | |
287 | - | |
288 | - } | |
289 | - | |
100 | + GetModulesBasedOnUserType(userInfo); | |
101 | + | |
290 | 102 | } |
291 | - else | |
292 | - { | |
103 | + else{ | |
293 | 104 | userInfo.IsBlocked = true; |
294 | 105 | } |
295 | - } | |
106 | + } | |
107 | + } | |
108 | + else | |
109 | + { | |
110 | + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_NOT_ACTIVE; | |
111 | + } | |
112 | + } | |
113 | + | |
114 | + else | |
115 | + { | |
296 | 116 | |
297 | - else | |
298 | - { | |
299 | 117 | |
300 | - //bool isCorrectLoginId, isCorrectPassword; | |
301 | - //AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, out isCorrectLoginId, out isCorrectPassword); | |
302 | - | |
303 | - //below code commented as way of retrieving data changed 'very first line in this method' | |
304 | - //if (!isCorrectLoginId) | |
305 | - //{ | |
306 | - // // send message back to th UI that login id is incorrect | |
307 | - // authenticationRepsonse = AIAConstants.USER_NOT_FOUND; | |
308 | - //} | |
309 | - //else | |
310 | - //{ | |
311 | - if (!isCorrectPassword) | |
118 | + //NIKITA. in this case user will come only when its is not authenticated and authenticity is checked based on userID and password | |
119 | + //and validating we have got record of user based on userd so this is the case when password is incorrect | |
120 | + userInfo.IsCorrectPassword = false; | |
121 | + if (userInfo.IsCorrectPassword == false) | |
312 | 122 | { |
313 | 123 | // send message back to th UI that password is incorrect |
314 | - userInfo.IsCorrectPassword = false; | |
124 | + // userInfo.IsCorrectPassword = false; | |
315 | 125 | |
316 | 126 | //get wrong attempt count of user |
317 | - userInfo.IncorrectLoginAttemptCount = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id) + 1; | |
127 | + int previousIncorrectLoginAttempts = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id); | |
128 | + userInfo.IncorrectLoginAttemptCount = previousIncorrectLoginAttempts + 1; | |
318 | 129 | userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH; |
319 | 130 | |
320 | 131 | //01. insert wrong attempt in dtabase |
321 | - int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptofUser(userInfo.Id); | |
132 | + int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptOfUser(userInfo.Id, previousIncorrectLoginAttempts); | |
322 | 133 | |
323 | 134 | if (updateCount < 0) |
324 | 135 | { |
325 | 136 | //Put the log in log file |
326 | 137 | logger.Fatal("Unable to Update past wrong login attempts for userId= " + userInfo.Id); |
327 | 138 | } |
328 | - else | |
329 | - { | |
139 | + //else | |
140 | + //{ | |
330 | 141 | if (userInfo.IncorrectLoginAttemptCount > 4) |
331 | 142 | { |
332 | 143 | userInfo.IsBlocked = true; |
333 | 144 | userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; |
334 | 145 | } |
335 | - } | |
146 | + //} | |
336 | 147 | } |
337 | 148 | } |
338 | 149 | // unreachable code detected as license is null |
... | ... | @@ -345,12 +156,12 @@ namespace AIAHTML5.API.Controllers |
345 | 156 | |
346 | 157 | authenticationRepsonse = JsonConvert.SerializeObject(userInfo); |
347 | 158 | //} |
348 | - } | |
349 | - } | |
350 | - else | |
351 | - { | |
159 | + } | |
160 | + | |
161 | + else | |
162 | + { | |
352 | 163 | authenticationRepsonse = AIAConstants.USER_NOT_FOUND; |
353 | - } | |
164 | + } | |
354 | 165 | } |
355 | 166 | catch (Exception e) |
356 | 167 | { |
... | ... | @@ -367,6 +178,85 @@ namespace AIAHTML5.API.Controllers |
367 | 178 | |
368 | 179 | return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) }; |
369 | 180 | } |
181 | + | |
182 | + private static void GetModulesBasedOnUserType(User userInfo) | |
183 | + { | |
184 | + if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN || userInfo.UserType == AIAHTML5.API.Models.User.GENERAL_ADMIN) | |
185 | + { | |
186 | + userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList(); | |
187 | + | |
188 | + //Insert user login detail | |
189 | + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
190 | + } | |
191 | + else | |
192 | + { | |
193 | + //05.1 For normal user need to get the license details, get the license id for authenticated user | |
194 | + int licenseId, editionId; | |
195 | + AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); | |
196 | + | |
197 | + userInfo.LicenseId = licenseId; | |
198 | + userInfo.EditionId = editionId; | |
199 | + | |
200 | + //05.2 Check user is active or not | |
201 | + | |
202 | + | |
203 | + //05.3 get license details | |
204 | + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId); | |
205 | + | |
206 | + // if (userInfo.LicenseInfo.Id > 0) | |
207 | + if (userInfo.LicenseInfo!= null) | |
208 | + { | |
209 | + //05.4 get licenseSubscription details | |
210 | + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); | |
211 | + | |
212 | + //05.5 check the License expiration irespective of either user is active or not because on AIA | |
213 | + //we shows the License expiration message for inactive users too | |
214 | + string expirationDate = null; | |
215 | + bool isLicenseExpired = false; | |
216 | + | |
217 | + if (userInfo.LicenseSubscriptions!= null) | |
218 | + { | |
219 | + isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate); | |
220 | + } | |
221 | + | |
222 | + // send message to the UI for license expiration | |
223 | + //05.6 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired] | |
224 | + if (isLicenseExpired) | |
225 | + { | |
226 | + userInfo.IsSubscriptionExpired = isLicenseExpired; | |
227 | + userInfo.SubscriptionExpirationDate = expirationDate; | |
228 | + } | |
229 | + else | |
230 | + { | |
231 | + //05.6.1 | |
232 | + if (userInfo.LicenseInfo.IsActive) | |
233 | + { | |
234 | + if (!userInfo.LicenseInfo.IsTermAccepted) | |
235 | + { | |
236 | + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsAndConditions(); | |
237 | + foreach (Hashtable item in termsList) | |
238 | + { | |
239 | + userInfo.TermsAndConditionsTitle = item[AIAConstants.KEY_TITLE].ToString(); | |
240 | + userInfo.TermsAndConditionsText = item[AIAConstants.KEY_CONTENT].ToString(); | |
241 | + } | |
242 | + } | |
243 | + else | |
244 | + { | |
245 | + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); | |
246 | + | |
247 | + //Insert user login detail | |
248 | + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
249 | + } | |
250 | + } | |
251 | + else | |
252 | + { | |
253 | + userInfo.LoginFailureCauseId = ErrorHelper.E_LICENCE_IS_INACTIVE; | |
254 | + | |
255 | + } | |
256 | + } | |
257 | + } | |
258 | + } | |
259 | + } | |
370 | 260 | |
371 | 261 | |
372 | 262 | // PUT api/authenticate/5 | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
... | ... | @@ -68,7 +68,7 @@ namespace AIAHTML5.API.Models |
68 | 68 | |
69 | 69 | DataSet ds = DBModel.GetDataFromStoredProcedure(sp); |
70 | 70 | |
71 | - if (ds.Tables.Count > 0) | |
71 | + if (ds!= null && ds.Tables.Count > 0) | |
72 | 72 | { |
73 | 73 | DataTable dt = ds.Tables[0]; |
74 | 74 | |
... | ... | @@ -182,7 +182,7 @@ namespace AIAHTML5.API.Models |
182 | 182 | adapter = new SqlDataAdapter(cmd); |
183 | 183 | adapter.Fill(ds); |
184 | 184 | |
185 | - if (ds.Tables.Count > 0) | |
185 | + if (ds!= null && ds.Tables.Count > 0) | |
186 | 186 | { |
187 | 187 | if (ds.Tables[0].Rows.Count > 0) |
188 | 188 | { |
... | ... | @@ -323,7 +323,7 @@ namespace AIAHTML5.API.Models |
323 | 323 | adapter.Fill(ds); |
324 | 324 | |
325 | 325 | |
326 | - if (ds.Tables.Count > 0) | |
326 | + if (ds!= null && ds.Tables.Count > 0) | |
327 | 327 | { |
328 | 328 | DataTable dt = ds.Tables[0]; |
329 | 329 | |
... | ... | @@ -407,7 +407,7 @@ namespace AIAHTML5.API.Models |
407 | 407 | ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); |
408 | 408 | logger.Debug(" Inside GetLicenseSubscriptionDetailsByLicenseId for LicenseId = " + licenseId); |
409 | 409 | |
410 | - LicenseSubscriptionDetails lsd = new LicenseSubscriptionDetails(); | |
410 | + LicenseSubscriptionDetails lsd = null; | |
411 | 411 | try |
412 | 412 | { |
413 | 413 | conn = new SqlConnection(dbConnectionString); |
... | ... | @@ -428,8 +428,9 @@ namespace AIAHTML5.API.Models |
428 | 428 | adapter = new SqlDataAdapter(cmd); |
429 | 429 | adapter.Fill(ds); |
430 | 430 | |
431 | - if (ds.Tables.Count > 0) | |
432 | - { | |
431 | + if (ds!= null && ds.Tables.Count > 0) | |
432 | + { | |
433 | + lsd = new LicenseSubscriptionDetails(); | |
433 | 434 | DataTable dt = ds.Tables[0]; |
434 | 435 | |
435 | 436 | if (dt.Rows.Count > 0) |
... | ... | @@ -452,11 +453,7 @@ namespace AIAHTML5.API.Models |
452 | 453 | } |
453 | 454 | } |
454 | 455 | } |
455 | - else | |
456 | - { | |
457 | - lsd = new LicenseSubscriptionDetails (); | |
458 | - } | |
459 | - | |
456 | + | |
460 | 457 | } |
461 | 458 | catch (Exception ex) |
462 | 459 | { |
... | ... | @@ -471,7 +468,7 @@ namespace AIAHTML5.API.Models |
471 | 468 | ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); |
472 | 469 | logger.Debug(" inside GetLicenseDetailsByLicenseId for LicenseId = " + licenseId); |
473 | 470 | |
474 | - License license = new License(); | |
471 | + License license = null; | |
475 | 472 | try |
476 | 473 | { |
477 | 474 | conn = new SqlConnection(dbConnectionString); |
... | ... | @@ -492,8 +489,10 @@ namespace AIAHTML5.API.Models |
492 | 489 | adapter = new SqlDataAdapter(cmd); |
493 | 490 | adapter.Fill(ds); |
494 | 491 | |
495 | - if (ds.Tables.Count > 0) | |
496 | - { | |
492 | + if (ds!= null && ds.Tables.Count > 0) | |
493 | + { | |
494 | + license = new License(); | |
495 | + | |
497 | 496 | DataTable dt = ds.Tables[0]; |
498 | 497 | if (dt.Rows.Count > 0) |
499 | 498 | { |
... | ... | @@ -526,10 +525,7 @@ namespace AIAHTML5.API.Models |
526 | 525 | } |
527 | 526 | } |
528 | 527 | } |
529 | - else | |
530 | - { | |
531 | - license = new License (); | |
532 | - } | |
528 | + | |
533 | 529 | } |
534 | 530 | catch (Exception ex) |
535 | 531 | { |
... | ... | @@ -566,21 +562,21 @@ namespace AIAHTML5.API.Models |
566 | 562 | return result; |
567 | 563 | } |
568 | 564 | |
569 | - internal static ArrayList GetTermsOfServiceText() | |
565 | + internal static ArrayList GetTermsAndConditions() | |
570 | 566 | { |
571 | 567 | ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); |
572 | - logger.Debug(" inside GetTermsOfServiceText"); | |
568 | + logger.Debug(" inside GetTermsAndConditions"); | |
573 | 569 | |
574 | - ArrayList arrTermsOfService = new ArrayList(); | |
570 | + ArrayList arrTermsAndConditions = new ArrayList(); | |
575 | 571 | |
576 | 572 | try |
577 | 573 | { |
578 | 574 | Hashtable contentHash = null; |
579 | - string str = string.Empty; | |
580 | - string spName = DBConstants.GET_TERMS_OF_SERVICE_TEXT; | |
581 | - DataSet ds = DBModel.GetDataFromStoredProcedure(spName); | |
582 | - | |
583 | - if (ds.Tables.Count > 0) | |
575 | + string str = string.Empty; | |
576 | + string spName = DBConstants.GET_TERMS_AND_CONDITIONS; | |
577 | + DataSet ds = DBModel.GetDataFromStoredProcedure(spName); | |
578 | + | |
579 | + if (ds!= null && ds.Tables.Count > 0) | |
584 | 580 | { |
585 | 581 | DataTable dt = ds.Tables[0]; |
586 | 582 | if (dt.Rows.Count > 0) |
... | ... | @@ -589,19 +585,19 @@ namespace AIAHTML5.API.Models |
589 | 585 | { |
590 | 586 | contentHash = new Hashtable(); |
591 | 587 | contentHash.Add(AIAConstants.KEY_TITLE, dr["Title"]); |
592 | - contentHash.Add(AIAConstants.KEY_CONTENT, dr["Content"]); | |
593 | - arrTermsOfService.Add(contentHash); | |
588 | + contentHash.Add(AIAConstants.KEY_CONTENT, dr["Content"]); | |
589 | + arrTermsAndConditions.Add(contentHash); | |
594 | 590 | } |
595 | 591 | } |
596 | 592 | } |
597 | 593 | } |
598 | 594 | catch (SqlException ex) |
599 | 595 | { |
600 | - logger.Fatal("Exception in GetTermsOfServiceText, Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace); | |
596 | + logger.Fatal("Exception in GetTermsAndConditions, Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace); | |
601 | 597 | throw; |
602 | - } | |
603 | - | |
604 | - return arrTermsOfService; | |
598 | + } | |
599 | + | |
600 | + return arrTermsAndConditions; | |
605 | 601 | } |
606 | 602 | |
607 | 603 | internal int InsertLoginDetails(int userId) |
... | ... | @@ -686,7 +682,7 @@ namespace AIAHTML5.API.Models |
686 | 682 | DataSet ds = new DataSet(); |
687 | 683 | da.Fill(ds); |
688 | 684 | |
689 | - if (ds.Tables.Count > 0) | |
685 | + if (ds!= null && ds.Tables.Count > 0) | |
690 | 686 | { |
691 | 687 | DataTable dt = ds.Tables[0]; |
692 | 688 | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/User.cs
... | ... | @@ -37,8 +37,8 @@ namespace AIAHTML5.API.Models |
37 | 37 | public LicenseSubscriptionDetails LicenseSubscriptions { get; set; } |
38 | 38 | public bool IsSubscriptionExpired { get; set; } |
39 | 39 | public string SubscriptionExpirationDate { get; set; } |
40 | - public string TermsOfServiceTitle { get; set; } | |
41 | - public string TermsOfServiceText { get; set; } | |
40 | + public string TermsAndConditionsTitle { get; set; } | |
41 | + public string TermsAndConditionsText { get; set; } | |
42 | 42 | |
43 | 43 | public const string SUPER_ADMIN = "Super Admin"; |
44 | 44 | public const string GENERAL_ADMIN = "General Admin"; | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... | ... | @@ -218,12 +218,7 @@ namespace AIAHTML5.API.Models |
218 | 218 | |
219 | 219 | logger.Fatal("Exception in getUserDetails for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); |
220 | 220 | throw; |
221 | - //ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
222 | - //string mailSubject = "SQL Exception intimation mail"; | |
223 | - //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
224 | - //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); | |
225 | - | |
226 | - //userDetails = AIAConstants.SQL_CONNECTION_ERROR; | |
221 | + | |
227 | 222 | } |
228 | 223 | |
229 | 224 | return userDetails; |
... | ... | @@ -298,7 +293,7 @@ namespace AIAHTML5.API.Models |
298 | 293 | expirationDate = string.Empty; |
299 | 294 | bool isLicenseExpired = false; |
300 | 295 | |
301 | - if (subscriptionDetail.Id > 0) | |
296 | + if (subscriptionDetail!= null) | |
302 | 297 | { |
303 | 298 | DateTime? subscriptionValidThrough = subscriptionDetail.SubscriptionValidThrough; |
304 | 299 | if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date) |
... | ... | @@ -378,7 +373,7 @@ namespace AIAHTML5.API.Models |
378 | 373 | return result; |
379 | 374 | } |
380 | 375 | |
381 | - internal static int saveWrongAttemptofUser(int userId) | |
376 | + internal static int saveWrongAttemptOfUser(int userId, int previousIncorrectLoginAttempts) | |
382 | 377 | { |
383 | 378 | ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); |
384 | 379 | logger.Debug("inside saveWrongAttemptofUser for UserId =" + userId); |
... | ... | @@ -386,11 +381,11 @@ namespace AIAHTML5.API.Models |
386 | 381 | |
387 | 382 | try |
388 | 383 | { |
389 | - int wrongAttemptCount = Users.checkNoOfWrongAttempts(userId); | |
384 | + // int wrongAttemptCount = Users.checkNoOfWrongAttempts(userId); | |
390 | 385 | |
391 | 386 | DBModel objModel = new DBModel(); |
392 | 387 | |
393 | - if (wrongAttemptCount < 1) | |
388 | + if (previousIncorrectLoginAttempts < 1) | |
394 | 389 | { |
395 | 390 | result = objModel.InsertIncorrectLoginAttempts(userId); |
396 | 391 | } |
... | ... | @@ -510,7 +505,7 @@ namespace AIAHTML5.API.Models |
510 | 505 | } |
511 | 506 | |
512 | 507 | |
513 | - internal static ArrayList getTermsOfServiceText() | |
508 | + internal static ArrayList getTermsAndConditions() | |
514 | 509 | { |
515 | 510 | ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); |
516 | 511 | logger.Debug("inside getTermsOfServiceText"); |
... | ... | @@ -520,7 +515,7 @@ namespace AIAHTML5.API.Models |
520 | 515 | try |
521 | 516 | { |
522 | 517 | DBModel objModel = new DBModel(); |
523 | - arrTermsOfService = DBModel.GetTermsOfServiceText(); | |
518 | + arrTermsOfService = DBModel.GetTermsAndConditions(); | |
524 | 519 | } |
525 | 520 | catch (Exception e) |
526 | 521 | { | ... | ... |