Commit 0a3aabc016546249da29cf7c8a4abcc15a4f7e90
1 parent
0abda49b
committing updated files
Showing
6 changed files
with
159 additions
and
153 deletions
400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj
... | ... | @@ -108,6 +108,7 @@ |
108 | 108 | <ItemGroup> |
109 | 109 | <Compile Include="App_Start\WebApiConfig.cs" /> |
110 | 110 | <Compile Include="Constants\AIAConstants.cs" /> |
111 | + <Compile Include="Constants\DBConstants.cs" /> | |
111 | 112 | <Compile Include="Constants\ErrorHelper.cs" /> |
112 | 113 | <Compile Include="Controllers\AdminAccessController.cs" /> |
113 | 114 | <Compile Include="Controllers\AuthenticateController.cs" /> | ... | ... |
400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs
... | ... | @@ -18,10 +18,6 @@ namespace AIAHTML5.API.Constants |
18 | 18 | public const string KEY_NAME = "name"; |
19 | 19 | public const string KEY_SLUG = "slug"; |
20 | 20 | public const string KEY_DESCRIPTION = "Description"; |
21 | - public const string KEY_LICENSE = "LICENSE"; | |
22 | - public const string KEY_EDITION = "EDITION"; | |
23 | - public const string KEY_LOGINID = "LOGINID"; | |
24 | - public const string KEY_PASSWORD = "PASSWORD"; | |
25 | 21 | |
26 | 22 | public const string PASSWORD_UPDATE_SUCCESS = "Password updated successfully"; |
27 | 23 | public const string PASSWORD_UPDATE_FAILED = "Password update failed"; | ... | ... |
400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs
0 → 100644
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Web; | |
5 | + | |
6 | +namespace AIAHTML5.API.Constants | |
7 | +{ | |
8 | + public class DBConstants | |
9 | + { | |
10 | + public const string GET_ALL_MODULES = "GetAllModuleStatusWithSlug"; | |
11 | + public const string GET_USER_DELAILS_BY_LOGIN_ID = "GetUserDetailsByLoginId"; | |
12 | + public const string GET_LICENSE_DETAILS_BY_USER_ID = "GetLicenseDetailByUserId"; | |
13 | + public const string GET_USER_MODULES_BY_LICENSE_ID = "GetUserModulesByLicenseId"; | |
14 | + public const string GET_USER_DETAILS_BY_EMAILID = "GetUserInfoByEmailId"; | |
15 | + | |
16 | + public const string UPDATE_USER_PASSWORD = "UpdateUserPassword"; | |
17 | + public const string GET_SUBSCRIPTION_DETAILS_BY_LICENSE_ID = "GetSubscriptionDetailsByLicenseId"; | |
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"; | |
21 | + public const string INSERT_LOGIN_DETAIL = "InsertLoginDetail"; | |
22 | + public const string INSERT_INCORRECT_LOGIN_ATTEMPTS = "InsertIncorrectLoginAttempt"; | |
23 | + public const string GET_INCORRECT_LOGIN_ATTEMPTS = "GetIncorrectLoginAttempt"; | |
24 | + public const string UPDATE_INCORRECT_LOGIN_ATTEMPTS = "UpdateIncorrectLoginAttempts"; | |
25 | + public const string DELETE_INCORRECT_LOGIN_ATTEMPTS = "DeleteIncorrectLoginAttempts"; | |
26 | + public const string GET_ALL_LOGIN_FAILURE_CAUSES = "GetAllLoginFailureCauses"; | |
27 | + public const string INSERT_LOGIN_ERROR_LOG = "InsertLoginErrorLog"; | |
28 | + public const string GET_BLOCKED_USER_BY_USER_ID = "GetBlockedUserByUserId"; | |
29 | + public const string GET_BLOCKED_USERS_BY_USER_TYPE = "GetBlockedUserByUserType"; | |
30 | + } | |
31 | +} | |
0 | 32 | \ No newline at end of file | ... | ... |
400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs
... | ... | @@ -34,113 +34,126 @@ namespace AIAHTML5.API.Controllers |
34 | 34 | logger.Debug("inside POST"); |
35 | 35 | |
36 | 36 | dynamic authenticationRepsonse; |
37 | - | |
37 | + | |
38 | 38 | //01. check user is authenticated or not by login credential macth |
39 | - bool isUserAuthenticated = AIAHTML5.API.Models.Users.IsUserAuthenticated(credentials); | |
39 | + //bool isUserAuthenticated = AIAHTML5.API.Models.Users.IsUserAuthenticated(credentials); | |
40 | + | |
41 | + //Above code commented to reduce dbhitting for same result set | |
40 | 42 | |
41 | - User userInfo = new Models.User(); | |
43 | + User userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); | |
44 | + //check is user authenticated | |
45 | + bool isUserAuthenticated = AIAHTML5.API.Models.Users.IsUserAuthenticated(credentials, userInfo); | |
42 | 46 | |
43 | - //02. Get User details | |
44 | - userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); | |
45 | 47 | |
46 | - if(isUserAuthenticated) | |
48 | + if (isUserAuthenticated) | |
47 | 49 | { |
48 | - //04.insert Log login details | |
49 | - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
50 | 50 | |
51 | - //03.delete past wrong login attempts of user | |
52 | - userInfo.IsCorrectLoginId = true; | |
51 | + //01. Get User details | |
52 | + //userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); | |
53 | + | |
54 | + //02. assigning isCorrectPassword to true 'required for internal processing' | |
53 | 55 | userInfo.IsCorrectPassword = true; |
54 | 56 | |
55 | - int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); | |
56 | - if (wrongAttemptDeteledCount < 0) | |
57 | + //03.insert Log login details | |
58 | + // Below statement executing irrespective of the fact user license inactive | |
59 | + //AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
60 | + | |
61 | + //04.delete past wrong login attempts of user | |
62 | + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); | |
63 | + if (wrongAttemptDeteledCount <= 0) | |
57 | 64 | { |
58 | - logger.Fatal("Unable to delete past wrong login attempts for userId= "+userInfo.Id); | |
65 | + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); | |
59 | 66 | } |
60 | 67 | |
61 | - // for ADMIN (superadmin/ general admin) users by default all module loads | |
68 | + //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads | |
62 | 69 | if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN || userInfo.UserType == AIAHTML5.API.Models.User.GENERAL_ADMIN) |
63 | 70 | { |
64 | 71 | userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList(); |
65 | - | |
72 | + | |
73 | + //Insert user login detail | |
74 | + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
66 | 75 | } |
67 | 76 | else |
68 | 77 | { |
69 | - //03. get the license id for aUTHENTICATED USER | |
70 | - userInfo.LicenseId = AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, "license"); | |
71 | - userInfo.EditionId = AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, "edition"); | |
72 | - | |
73 | - //05.Check user is active or not | |
74 | - // Below statement required as tl says it is required for better code readability | |
75 | - userInfo.IsActive = userInfo.IsActive; | |
78 | + //CORRECT CODE | |
79 | + //05.1 For normal user need to get the license details, get the license id for aUTHENTICATED USER | |
80 | + int licenseId, editionId; | |
81 | + AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); | |
82 | + | |
83 | + userInfo.LicenseId = licenseId; | |
84 | + userInfo.EditionId = editionId; | |
76 | 85 | |
86 | + //05.2 Check user is active or not | |
77 | 87 | |
78 | - //5.1 get license/ licenseSubscription details | |
79 | - //objUser.License.IsActive = AIAHTML5.API.Models.Users.isLicenseActive(objUser.LicenseId); | |
80 | - userInfo.License = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId); | |
81 | - userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); | |
82 | - | |
83 | - //5.2 check the License expiration irespective of either user is active or not because on AIA | |
84 | - //we shows the License expiration message for inactive users too | |
85 | - bool isLicenseSubscriptionExpired = false; | |
86 | - string expirationDate = AIAHTML5.API.Models.Users.getLicenseExpirationDate(userInfo.LicenseId,out isLicenseSubscriptionExpired); | |
87 | - | |
88 | - // send message to the UI for license expiration | |
89 | - //5.2 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired] | |
90 | - if (isLicenseSubscriptionExpired) | |
91 | - { | |
92 | - userInfo.IsSubscriptionExpired = isLicenseSubscriptionExpired; | |
93 | - userInfo.SubscriptionExpirationDate = expirationDate; | |
94 | - } | |
95 | - | |
96 | - if (userInfo.License.IsActive) | |
97 | - { | |
98 | - //Insert user login details | |
99 | - //AIAHTML5.API.Models.Users.insertLoginDetails(objUser.Id); | |
100 | 88 | |
101 | - if (!userInfo.License.IsTermAccepted) | |
102 | - { | |
103 | - ArrayList termsList = AIAHTML5.API.Models.Users.getTermsOfServiceText(); | |
104 | - foreach (Hashtable item in termsList) | |
105 | - { | |
106 | - userInfo.TermsOfServiceTitle = item["title"].ToString(); | |
107 | - userInfo.TermsOfServiceText = item["content"].ToString(); | |
108 | - } | |
109 | - } | |
110 | - else | |
89 | + //05.3 get license/ licenseSubscription details | |
90 | + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId); | |
91 | + | |
92 | + //05.4 | |
93 | + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); | |
94 | + | |
95 | + //05.5 check the License expiration irespective of either user is active or not because on AIA | |
96 | + //we shows the License expiration message for inactive users too | |
97 | + string expirationDate = null; | |
98 | + | |
99 | + bool isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate); | |
100 | + | |
101 | + // send message to the UI for license expiration | |
102 | + //05.6 Check for subscription Expiration [Promoted for case if license inactive along with subscription expired] | |
103 | + if (isLicenseExpired) | |
104 | + { | |
105 | + userInfo.IsSubscriptionExpired = isLicenseExpired; | |
106 | + userInfo.SubscriptionExpirationDate = expirationDate; | |
107 | + } | |
108 | + else | |
109 | + { | |
110 | + //05.6.1 | |
111 | + if (userInfo.LicenseInfo.IsActive) | |
112 | + { | |
113 | + if (!userInfo.LicenseInfo.IsTermAccepted) | |
114 | + { | |
115 | + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsOfServiceText(); | |
116 | + foreach (Hashtable item in termsList) | |
111 | 117 | { |
112 | - userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); | |
118 | + userInfo.TermsOfServiceTitle = item["title"].ToString(); | |
119 | + userInfo.TermsOfServiceText = item["content"].ToString(); | |
113 | 120 | } |
114 | 121 | } |
115 | - | |
116 | - //else | |
117 | - //{ | |
118 | - // //6. | |
122 | + else | |
123 | + { | |
124 | + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); | |
119 | 125 | |
126 | + //Insert user login detail | |
127 | + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); | |
128 | + } | |
129 | + } | |
130 | + else | |
131 | + { | |
132 | + //05.6.1.1 | |
133 | + // return message of license inactive | |
134 | + // property value assigned. Separate return statement not required | |
120 | 135 | |
121 | - // // now return this list to the UI | |
122 | - //} | |
123 | - //} | |
124 | - //else | |
125 | - //{ | |
126 | - // // send message back to th UI that user is inactive | |
127 | - //} | |
136 | + } | |
137 | + | |
138 | + } | |
128 | 139 | } |
129 | 140 | |
141 | + authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
130 | 142 | } |
131 | 143 | else |
132 | 144 | { |
133 | - bool isCorrectLoginId = AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, "loginId"); | |
145 | + bool isCorrectLoginId, isCorrectPassword; | |
146 | + AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, out isCorrectLoginId, out isCorrectPassword); | |
134 | 147 | |
135 | 148 | if (!isCorrectLoginId) |
136 | 149 | { |
137 | 150 | // send message back to th UI that login id is incorrect |
138 | - userInfo.IsCorrectLoginId = isCorrectLoginId; | |
151 | + authenticationRepsonse = AIAConstants.USER_NOT_FOUND; | |
139 | 152 | } |
140 | 153 | else |
141 | 154 | { |
142 | - userInfo.IsCorrectLoginId = true; | |
143 | - bool isCorrectPassword = AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, "password"); | |
155 | + //getting userDetails | |
156 | + userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); | |
144 | 157 | |
145 | 158 | if (!isCorrectPassword) |
146 | 159 | { |
... | ... | @@ -148,7 +161,7 @@ namespace AIAHTML5.API.Controllers |
148 | 161 | userInfo.IsCorrectPassword = false; |
149 | 162 | |
150 | 163 | //get wrong attempt count of user |
151 | - userInfo.IncorrectLoginAttemptCount = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id) + 1; | |
164 | + userInfo.IncorrectLoginAttemptCount = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id) +1; | |
152 | 165 | userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH; |
153 | 166 | |
154 | 167 | //01. insert wrong attempt in dtabase |
... | ... | @@ -161,19 +174,6 @@ namespace AIAHTML5.API.Controllers |
161 | 174 | } |
162 | 175 | else |
163 | 176 | { |
164 | - | |
165 | - //02. check no of wrong attempts | |
166 | - //userInfo.IncorrectLoginAttemptCount = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id); | |
167 | - //if (userInfo.IncorrectLoginAttemptCount >= 5) | |
168 | - //{ | |
169 | - // userInfo.IsBlocked = true; | |
170 | - // // send block message | |
171 | - //} | |
172 | - //else | |
173 | - //{ | |
174 | - // // send message back to UI for login fail | |
175 | - //} | |
176 | - | |
177 | 177 | if (userInfo.IncorrectLoginAttemptCount > 4) |
178 | 178 | { |
179 | 179 | userInfo.IsBlocked = true; |
... | ... | @@ -188,25 +188,22 @@ namespace AIAHTML5.API.Controllers |
188 | 188 | // if (result < 0) |
189 | 189 | // logger.Fatal("Unable to insert wrong attempt detail in UserLoginLog table for accountNumber= " + userInfo.License.AccountNumber); |
190 | 190 | //} |
191 | + | |
192 | + authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
191 | 193 | } |
192 | 194 | } |
193 | 195 | |
194 | - if(userInfo.IsCorrectLoginId) | |
195 | - authenticationRepsonse = JsonConvert.SerializeObject(userInfo); | |
196 | - else | |
197 | - authenticationRepsonse = AIAConstants.USER_NOT_FOUND; | |
198 | - | |
199 | - //if (Convert.ToString(authenticationRepsonse) != AIAConstants.USER_NOT_FOUND && Convert.ToString(authenticationRepsonse) != AIAConstants.ERROR_IN_FECTHING_DETAILS && Convert.ToString(authenticationRepsonse)!= AIAConstants.SQL_CONNECTION_ERROR) | |
200 | - //{ | |
201 | - // //string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(authenticationRepsonse); | |
202 | - // return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) }; | |
203 | - //} | |
204 | - //else | |
205 | - //{ | |
206 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) }; | |
207 | - | |
208 | - //} | |
209 | - } | |
196 | + //if (Convert.ToString(authenticationRepsonse) != AIAConstants.USER_NOT_FOUND && Convert.ToString(authenticationRepsonse) != AIAConstants.ERROR_IN_FECTHING_DETAILS && Convert.ToString(authenticationRepsonse)!= AIAConstants.SQL_CONNECTION_ERROR) | |
197 | + //{ | |
198 | + // //string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(authenticationRepsonse); | |
199 | + // return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) }; | |
200 | + //} | |
201 | + //else | |
202 | + //{ | |
203 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) }; | |
204 | + | |
205 | + //} | |
206 | + } | |
210 | 207 | |
211 | 208 | |
212 | 209 | // PUT api/authenticate/5 | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/User.cs
... | ... | @@ -24,7 +24,6 @@ namespace AIAHTML5.API.Models |
24 | 24 | public string UserType { get; set; } |
25 | 25 | public int UserTypeId { get; set; } |
26 | 26 | public bool IsActive { get; set; } |
27 | - public bool IsCorrectLoginId { get; set; } | |
28 | 27 | public bool IsCorrectPassword { get; set; } |
29 | 28 | public int IncorrectLoginAttemptCount { get; set; } |
30 | 29 | public bool IsBlocked { get; set; } |
... | ... | @@ -34,7 +33,7 @@ namespace AIAHTML5.API.Models |
34 | 33 | |
35 | 34 | public ArrayList Modules { get; set; } |
36 | 35 | |
37 | - public License License { get; set; } | |
36 | + public License LicenseInfo { get; set; } | |
38 | 37 | public LicenseSubscriptionDetails LicenseSubscriptions { get; set; } |
39 | 38 | public bool IsSubscriptionExpired { get; set; } |
40 | 39 | public string SubscriptionExpirationDate { get; set; } | ... | ... |
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... | ... | @@ -23,7 +23,7 @@ namespace AIAHTML5.API.Models |
23 | 23 | |
24 | 24 | try |
25 | 25 | { |
26 | - User user = DBModel.GetUserDetailsByLoginIdAndPassword(credentials["username"].ToString(), credentials["password"].ToString()); | |
26 | + User user = DBModel.GetUserDetailsByLoginId(credentials["username"].ToString()); | |
27 | 27 | //string userDetails = DBModel.GetUserDetailsByLoginId2(credentials["username"].ToString()); |
28 | 28 | |
29 | 29 | if (user != null) |
... | ... | @@ -196,33 +196,29 @@ namespace AIAHTML5.API.Models |
196 | 196 | return result; |
197 | 197 | } |
198 | 198 | |
199 | - internal static bool IsUserAuthenticated(Newtonsoft.Json.Linq.JObject credentials) | |
199 | + internal static bool IsUserAuthenticated(Newtonsoft.Json.Linq.JObject credentials, User user) | |
200 | 200 | { |
201 | - bool isAuthenticatedUser = DBModel.ValidateUserAuthenticity(credentials["username"].ToString(), credentials["password"].ToString()); | |
201 | + bool isAuthenticatedUser = DBModel.ValidateUserAuthenticity(credentials["username"].ToString(), credentials["password"].ToString(), user); | |
202 | 202 | |
203 | 203 | return isAuthenticatedUser; |
204 | 204 | } |
205 | 205 | |
206 | - internal static User getLoggedinUserDetail(Newtonsoft.Json.Linq.JObject credentials) | |
207 | - { | |
208 | - User user = DBModel.GetUserDetailsByLoginIdAndPassword(credentials["username"].ToString(), credentials["password"].ToString()); | |
209 | - | |
210 | - return user; | |
211 | - } | |
212 | - | |
213 | 206 | internal static User getUserDetails(Newtonsoft.Json.Linq.JObject credentials) |
214 | 207 | { |
215 | - User user = DBModel.GetUserDetailsByLoginIdAndPassword(credentials["username"].ToString(), credentials["password"].ToString()); | |
208 | + User user = DBModel.GetUserDetailsByLoginId(credentials["username"].ToString()); | |
216 | 209 | |
217 | 210 | return user; |
218 | 211 | } |
219 | 212 | |
220 | - internal static int getLicenseIdForThisUser(int userId, string key) | |
213 | + internal static void getLicenseIdForThisUser(int userId, out int licenseId, out int editionId) | |
221 | 214 | { |
215 | + //assigning below variable to avoid compiler error for unassignd out params | |
216 | + licenseId = 0; | |
217 | + editionId = 0; | |
218 | + | |
222 | 219 | ArrayList arrLicense = new ArrayList(); |
223 | 220 | DBModel objModel = new DBModel(); |
224 | - int licenseId = 0 , editionId = 0, result = 0; | |
225 | - Hashtable licenseEditionHash = objModel.GetUserLicenseDetailByUserId(userId); | |
221 | + Hashtable licenseEditionHash = objModel.GetLicenseDetailByUserId(userId); | |
226 | 222 | foreach (DictionaryEntry de in licenseEditionHash) |
227 | 223 | { |
228 | 224 | if (de.Key.ToString() == AIAConstants.LICENSE_KEY_ID) |
... | ... | @@ -230,12 +226,6 @@ namespace AIAHTML5.API.Models |
230 | 226 | if (de.Key.ToString() == AIAConstants.EDITION_KEY_ID) |
231 | 227 | editionId = Convert.ToInt32(de.Value); |
232 | 228 | } |
233 | - | |
234 | - if (string.Equals(key.ToUpper(), AIAConstants.KEY_LICENSE)) | |
235 | - result = licenseId; | |
236 | - if (string.Equals(key.ToUpper(), AIAConstants.KEY_EDITION)) | |
237 | - result = editionId; | |
238 | - return result; | |
239 | 229 | } |
240 | 230 | |
241 | 231 | internal static int insertLoginDetails(int userId) |
... | ... | @@ -256,16 +246,14 @@ namespace AIAHTML5.API.Models |
256 | 246 | return false; |
257 | 247 | } |
258 | 248 | |
259 | - internal static string getLicenseExpirationDate(int licenseId, out bool isLicenseExpired) | |
249 | + internal static bool checkIfLicenseExpired(LicenseSubscriptionDetails subscriptionDetail, out string expirationDate) | |
260 | 250 | { |
261 | - isLicenseExpired = false; | |
262 | - DBModel objModel = new DBModel(); | |
263 | - LicenseSubscriptionDetails licenseSubscription = objModel.GetLicenseSubscriptionDetailsByLicenseId(licenseId); | |
264 | - string subscritptionExpirationDate = null; | |
251 | + expirationDate = string.Empty; | |
252 | + bool isLicenseExpired = false; | |
265 | 253 | |
266 | - if (licenseSubscription != null) | |
254 | + if (subscriptionDetail != null) | |
267 | 255 | { |
268 | - DateTime? subscriptionValidThrough = licenseSubscription.SubscriptionValidThrough; | |
256 | + DateTime? subscriptionValidThrough = subscriptionDetail.SubscriptionValidThrough; | |
269 | 257 | if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date) |
270 | 258 | { |
271 | 259 | isLicenseExpired = false; |
... | ... | @@ -273,10 +261,10 @@ namespace AIAHTML5.API.Models |
273 | 261 | else |
274 | 262 | { |
275 | 263 | isLicenseExpired = true; |
276 | - subscritptionExpirationDate = licenseSubscription.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString(); | |
264 | + expirationDate = subscriptionDetail.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString(); | |
277 | 265 | } |
278 | 266 | } |
279 | - return subscritptionExpirationDate; | |
267 | + return isLicenseExpired; | |
280 | 268 | } |
281 | 269 | |
282 | 270 | internal static ArrayList getModuleListByLicenseId(int licenseId) |
... | ... | @@ -352,29 +340,23 @@ namespace AIAHTML5.API.Models |
352 | 340 | return userSubscriptionDetail; |
353 | 341 | } |
354 | 342 | |
355 | - internal static bool isCredentialCorrect(Newtonsoft.Json.Linq.JObject credentials, User user, string key) | |
343 | + internal static void isCredentialCorrect(Newtonsoft.Json.Linq.JObject credentials, out bool isCorrectLoginId, out bool isCorrectPassword) | |
356 | 344 | { |
357 | - bool result = false; | |
358 | - if (user != null) | |
345 | + isCorrectLoginId = false; | |
346 | + isCorrectPassword = false; | |
347 | + | |
348 | + User userInfo = Users.getUserDetails(credentials); | |
349 | + | |
350 | + if (userInfo != null) | |
359 | 351 | { |
360 | - if (string.Equals(key.ToUpper(), AIAConstants.KEY_LOGINID)) | |
361 | - { | |
362 | - if (string.Equals(credentials["username"].ToString().ToUpper(), user.LoginId.ToUpper())) | |
363 | - result = true; | |
364 | - else | |
365 | - result = false; | |
366 | - } | |
352 | + if (string.Equals(credentials["username"].ToString().ToUpper(), userInfo.LoginId.ToUpper())) | |
353 | + isCorrectLoginId = true; | |
367 | 354 | |
368 | - if (string.Equals(key.ToUpper(), AIAConstants.KEY_PASSWORD)) | |
355 | + if (string.Equals(credentials["password"].ToString(), userInfo.Password)) | |
369 | 356 | { |
370 | - if (string.Equals(credentials["password"].ToString(), user.Password)) | |
371 | - result = true; | |
372 | - else | |
373 | - result = false; | |
357 | + isCorrectPassword = true; | |
374 | 358 | } |
375 | 359 | } |
376 | - | |
377 | - return result; | |
378 | 360 | } |
379 | 361 | |
380 | 362 | internal static int insertUserLoginLog(string accountNumber, Int16 failureId, string referalUrl, string edition, string httpReferer) |
... | ... | @@ -399,7 +381,7 @@ namespace AIAHTML5.API.Models |
399 | 381 | internal static ArrayList getAllModulesList() |
400 | 382 | { |
401 | 383 | DBModel objModel = new DBModel(); |
402 | - ArrayList modulesList = objModel.GetUserModules(); | |
384 | + ArrayList modulesList = objModel.GetAllModules(); | |
403 | 385 | |
404 | 386 | return modulesList; |
405 | 387 | } | ... | ... |