Commit df1d24b899413bd498f0a69c28ac0607cb5806f1

Authored by Utkarsh Singh
1 parent 6e1f4c28

Committing updated files

400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs
... ... @@ -19,5 +19,7 @@ namespace AIAHTML5.API.Constants
19 19  
20 20 public const string PASSWORD_UPDATE_SUCCESS = "Password updated successfully";
21 21 public const string PASSWORD_UPDATE_FAILED = "Password update failed";
  22 +
  23 + public const string INVALID_USER = "Invalid UserID";
22 24 }
23 25 }
24 26 \ No newline at end of file
... ...
400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs
... ... @@ -40,7 +40,7 @@ namespace AIAHTML5.API.Controllers
40 40 else
41 41 {
42 42  
43   - dynamic authenticationRepsonse = AIAHTML5.API.Models.Users.AuthenticateUser(credentials);
  43 + dynamic authenticationRepsonse = AIAHTML5.API.Models.Users.GetUserDetailsForAuthenticatedUser(credentials);
44 44 if (Convert.ToString(authenticationRepsonse) != AIAConstants.USER_NOT_FOUND && Convert.ToString(authenticationRepsonse) != AIAConstants.ERROR_IN_FECTHING_DETAILS)
45 45 {
46 46 //string userDetails = Newtonsoft.Json.JsonConvert.SerializeObject(authenticationRepsonse);
... ...
400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
... ... @@ -70,7 +70,7 @@ namespace AIAHTML5.API.Models
70 70 return arrUserModules;
71 71 }
72 72  
73   - public static dynamic GetUserDetailsByLoginIdAndPassword(string sLoginId, string sPassword)
  73 + public static dynamic GetUserDetailsByLoginIdAndPassword(string loginId, string password)
74 74 {
75 75 User objUser = new User();
76 76 DBModel objModel = new DBModel();
... ... @@ -85,12 +85,12 @@ namespace AIAHTML5.API.Models
85 85 cmd.CommandText = "GetUserDetailsByLoginIdAndPassword";
86 86 cmd.CommandType = CommandType.StoredProcedure;
87 87  
88   - param = new SqlParameter("@sLoginId", sLoginId);
  88 + param = new SqlParameter("@sLoginId", loginId);
89 89 param.Direction = ParameterDirection.Input;
90 90 param.DbType = DbType.String;
91 91 cmd.Parameters.Add(param);
92 92  
93   - param = new SqlParameter("@sPassword", sPassword);
  93 + param = new SqlParameter("@sPassword", password);
94 94 param.Direction = ParameterDirection.Input;
95 95 param.DbType = DbType.String;
96 96 cmd.Parameters.Add(param);
... ... @@ -155,10 +155,9 @@ namespace AIAHTML5.API.Models
155 155 }
156 156 }
157 157  
158   - if (objUser.IsActive)
  158 + if (objUser.LoginId != null)
159 159 {
160   -
161   - if (objUser != null)
  160 + if (objUser.IsActive)
162 161 {
163 162 if (objUser.UserType == User.SUPER_ADMIN)
164 163 {
... ... @@ -196,14 +195,12 @@ namespace AIAHTML5.API.Models
196 195 }
197 196 }
198 197 }
199   -
200   -
201 198 else
202 199 {
203 200 objUser.Modules = null;
204   - objUser = null;
  201 + objUser = new User();
  202 + objUser.License = null;
205 203 }
206   -
207 204 }
208 205 }
209 206 }
... ... @@ -215,7 +212,7 @@ namespace AIAHTML5.API.Models
215 212 return objUser;
216 213 }
217 214  
218   - protected int GetUserLicenseIdByUserId(int iUserId)
  215 + protected int GetUserLicenseIdByUserId(int userId)
219 216 {
220 217 int _licenseId = 0;
221 218 conn = new SqlConnection(dbConnectionString);
... ... @@ -228,7 +225,7 @@ namespace AIAHTML5.API.Models
228 225 cmd.CommandText = "GetLicenseIdByUserId";
229 226 cmd.CommandType = CommandType.StoredProcedure;
230 227  
231   - param = new SqlParameter("@iUserId", iUserId);
  228 + param = new SqlParameter("@iUserId", userId);
232 229 param.Direction = ParameterDirection.Input;
233 230 param.DbType = DbType.Int32;
234 231 cmd.Parameters.Add(param);
... ... @@ -240,7 +237,7 @@ namespace AIAHTML5.API.Models
240 237 return _licenseId;
241 238 }
242 239  
243   - protected ArrayList GetModuleStatusByLicenseId(int iLicenseId)
  240 + protected ArrayList GetModuleStatusByLicenseId(int licenseId)
244 241 {
245 242 ArrayList userModulelist = new ArrayList();
246 243 Hashtable modulesHash;
... ... @@ -255,7 +252,7 @@ namespace AIAHTML5.API.Models
255 252 cmd.CommandText = "GetModuleStatusByLicenseId";
256 253 cmd.CommandType = CommandType.StoredProcedure;
257 254  
258   - param = new SqlParameter("@iLicenseId", iLicenseId);
  255 + param = new SqlParameter("@iLicenseId", licenseId);
259 256 param.Direction = ParameterDirection.Input;
260 257 param.DbType = DbType.Int32;
261 258 cmd.Parameters.Add(param);
... ... @@ -280,17 +277,17 @@ namespace AIAHTML5.API.Models
280 277 {
281 278 ArrayList userModules = new ArrayList();
282 279 Hashtable moduleHash;
283   - foreach (Hashtable all in allModules)
  280 + foreach (Hashtable module in allModules)
284 281 {
285   - string slg = all["slug"].ToString();
286   - foreach (Hashtable user in modulesByLicense)
  282 + string slg = module["slug"].ToString();
  283 + foreach (Hashtable userModule in modulesByLicense)
287 284 {
288   - bool y = Convert.ToBoolean(user["Status"]);
289   - if ((user["Title"].ToString().Trim() == all["name"].ToString().Trim()) && (Convert.ToBoolean(user["Status"]) == true))
  285 + bool y = Convert.ToBoolean(userModule["Status"]);
  286 + if ((userModule["Title"].ToString().Trim() == module["name"].ToString().Trim()) && (Convert.ToBoolean(userModule["Status"]) == true))
290 287 {
291 288 moduleHash = new Hashtable();
292   - moduleHash.Add("name", user["Title"]);
293   - moduleHash.Add("slug", all["slug"]);
  289 + moduleHash.Add("name", userModule["Title"]);
  290 + moduleHash.Add("slug", module["slug"]);
294 291  
295 292 userModules.Add(moduleHash);
296 293 }
... ... @@ -300,11 +297,11 @@ namespace AIAHTML5.API.Models
300 297 return userModules;
301 298 }
302 299  
303   - protected string GetUserTypeStringById(int iUserTypeId)
  300 + protected string GetUserTypeStringById(int userTypeId)
304 301 {
305 302 string userType = string.Empty;
306 303  
307   - switch (iUserTypeId)
  304 + switch (userTypeId)
308 305 {
309 306 case 1:
310 307 userType = User.SUPER_ADMIN;
... ... @@ -337,7 +334,7 @@ namespace AIAHTML5.API.Models
337 334 return userType;
338 335 }
339 336  
340   - public static User GetUserDetailsByEmailId(string sEmailId)
  337 + public static User GetUserDetailsByEmailId(string emailId)
341 338 {
342 339 User objUser = new User();
343 340 DBModel objModel = new DBModel();
... ... @@ -354,7 +351,7 @@ namespace AIAHTML5.API.Models
354 351 cmd.CommandText = "GetUserInfoByEmailId";
355 352 cmd.CommandType = CommandType.StoredProcedure;
356 353  
357   - param = new SqlParameter("@sEmailId", sEmailId);
  354 + param = new SqlParameter("@sEmailId", emailId);
358 355 param.Direction = ParameterDirection.Input;
359 356 param.DbType = DbType.String;
360 357 cmd.Parameters.Add(param);
... ... @@ -418,7 +415,7 @@ namespace AIAHTML5.API.Models
418 415 return objUser;
419 416 }
420 417  
421   - public static int UpdateUserPassword(dynamic userInfo, string sLoginId, string sEmailId)
  418 + public static int UpdateUserPassword(dynamic userInfo, string loginId, string emailId)
422 419 {
423 420 int result = 0;
424 421 conn = new SqlConnection(dbConnectionString);
... ... @@ -427,15 +424,15 @@ namespace AIAHTML5.API.Models
427 424 conn.Open();
428 425 cmd.CommandText = "UpdateUserPassword";
429 426 cmd.CommandType = CommandType.StoredProcedure;
430   - cmd.Parameters.AddWithValue("@sLoginId", sLoginId);
431   - cmd.Parameters.AddWithValue("@sEmailId", sEmailId);
  427 + cmd.Parameters.AddWithValue("@sLoginId", loginId);
  428 + cmd.Parameters.AddWithValue("@sEmailId", emailId);
432 429 cmd.Parameters.AddWithValue("@sNewPassword", userInfo["newPassword"].ToString());
433 430 result = cmd.ExecuteNonQuery();
434 431 conn.Close();
435 432 return result;
436 433 }
437 434  
438   - protected LicenseSubscriptionDetails GetLicenseSubscriptionDetailsByLicenseId(int iLicenseId)
  435 + protected LicenseSubscriptionDetails GetLicenseSubscriptionDetailsByLicenseId(int licenseId)
439 436 {
440 437 LicenseSubscriptionDetails lsd = new LicenseSubscriptionDetails();
441 438 try
... ... @@ -450,7 +447,7 @@ namespace AIAHTML5.API.Models
450 447 cmd.CommandText = "GetSubscriptionDetailsByLicenseId";
451 448 cmd.CommandType = CommandType.StoredProcedure;
452 449  
453   - param = new SqlParameter("@iLicenseId", iLicenseId);
  450 + param = new SqlParameter("@iLicenseId", licenseId);
454 451 param.Direction = ParameterDirection.Input;
455 452 param.DbType = DbType.Int32;
456 453 cmd.Parameters.Add(param);
... ... @@ -513,7 +510,7 @@ namespace AIAHTML5.API.Models
513 510 return lsd;
514 511 }
515 512  
516   - protected License GetLicenseDetailsByLicenseId(int iLicenseId)
  513 + protected License GetLicenseDetailsByLicenseId(int licenseId)
517 514 {
518 515 License lic = new License();
519 516 try
... ... @@ -528,7 +525,7 @@ namespace AIAHTML5.API.Models
528 525 cmd.CommandText = "GetLicenseDetailsById";
529 526 cmd.CommandType = CommandType.StoredProcedure;
530 527  
531   - param = new SqlParameter("@Id", iLicenseId);
  528 + param = new SqlParameter("@Id", licenseId);
532 529 param.Direction = ParameterDirection.Input;
533 530 param.DbType = DbType.Int32;
534 531 cmd.Parameters.Add(param);
... ...
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... ... @@ -14,7 +14,7 @@ namespace AIAHTML5.API.Models
14 14 {
15 15 public class Users
16 16 {
17   - internal static dynamic AuthenticateUser(Newtonsoft.Json.Linq.JObject credentials)
  17 + internal static dynamic GetUserDetailsForAuthenticatedUser(Newtonsoft.Json.Linq.JObject credentials)
18 18 {
19 19 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
20 20 logger.Debug("inside AuthenticateUser for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString());
... ... @@ -42,13 +42,28 @@ namespace AIAHTML5.API.Models
42 42 //{
43 43 // return AIAConstants.USER_NOT_FOUND;
44 44 //}
45   - User oUser = DBModel.GetUserDetailsByLoginIdAndPassword(credentials["username"].ToString(), credentials["password"].ToString());
  45 + User user = DBModel.GetUserDetailsByLoginIdAndPassword(credentials["username"].ToString(), credentials["password"].ToString());
46 46 //string userDetails = DBModel.GetUserDetailsByLoginId2(credentials["username"].ToString());
47 47  
48   - if (oUser != null)
  48 + if (user != null)
49 49 {
50   - logger.Debug("userDetails.loginId= " + oUser.LoginId); // .loginId);
51   - userDetails = JsonConvert.SerializeObject(oUser);
  50 + logger.Debug("userDetails.loginId= " + user.LoginId); // .loginId);
  51 +
  52 + if (user.IsActive)
  53 + {
  54 + if (user.License != null)
  55 + {
  56 + userDetails = JsonConvert.SerializeObject(user);
  57 + }
  58 + else
  59 + {
  60 + userDetails = AIAConstants.INVALID_USER;
  61 + }
  62 + }
  63 + else
  64 + {
  65 + userDetails = AIAConstants.INVALID_USER;
  66 + }
52 67 }
53 68 else
54 69 {
... ...
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll
No preview for this file type
400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb
No preview for this file type
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -145,34 +145,41 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
145 145  
146 146 $("#messageModal").modal('hide');
147 147 }
148   -
149   - if ((!result.IsSubscriptionExpired) && (result.UserType == UserTypeConstants.SUPER_ADMIN)) {
150   - $rootScope.userData = result;
151   - $rootScope.userModules = result.Modules;
152   - $rootScope.isVisibleLogin = false;
153   - $rootScope.haveRoleAdmin = false;
154   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
155   - $('#dvUserModulesInfo').modal('show');
156   - }
157   - else if ((!result.IsSubscriptionExpired) && (result.License.IsActive)) {
158   -
159   - $rootScope.userData = result;
160   - $rootScope.userModules = result.Modules;
161   - $rootScope.isVisibleLogin = false;
162   - $rootScope.haveRoleAdmin = true;
163   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
164   - $('#dvUserModulesInfo').modal('show');
165   - }
166   - else if ((result.IsSubscriptionExpired) && (result.License.IsActive)) {
  148 + if (result == LoginMessageConstants.INVALID_USER) {
167 149 $rootScope.isVisibleLogin = true;
168   - $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
  150 + $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
169 151 $("#messageModal").modal('show');
170 152 }
171   - else if ((result.IsSubscriptionExpired) && !(result.License.IsActive)) {
172   - $rootScope.isVisibleLogin = true;
173   - $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
174   - $rootScope.errorMessage = $rootScope.errorMessage + ' '+ LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
175   - $("#messageModal").modal('show');
  153 + else {
  154 +
  155 + if ((!result.IsSubscriptionExpired) && (result.UserType == UserTypeConstants.SUPER_ADMIN)) {
  156 + $rootScope.userData = result;
  157 + $rootScope.userModules = result.Modules;
  158 + $rootScope.isVisibleLogin = false;
  159 + $rootScope.haveRoleAdmin = false;
  160 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  161 + $('#dvUserModulesInfo').modal('show');
  162 + }
  163 + else if ((!result.IsSubscriptionExpired) && (result.License.IsActive)) {
  164 +
  165 + $rootScope.userData = result;
  166 + $rootScope.userModules = result.Modules;
  167 + $rootScope.isVisibleLogin = false;
  168 + $rootScope.haveRoleAdmin = true;
  169 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  170 + $('#dvUserModulesInfo').modal('show');
  171 + }
  172 + else if ((result.IsSubscriptionExpired) && (result.License.IsActive)) {
  173 + $rootScope.isVisibleLogin = true;
  174 + $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
  175 + $("#messageModal").modal('show');
  176 + }
  177 + else if ((result.IsSubscriptionExpired) && !(result.License.IsActive)) {
  178 + $rootScope.isVisibleLogin = true;
  179 + $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
  180 + $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
  181 + $("#messageModal").modal('show');
  182 + }
176 183 }
177 184 }
178 185  
... ...
400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
... ... @@ -324,7 +324,8 @@ AIA.constant("LoginMessageConstants", {
324 324 "PASSWORD_UPDATE_SUCCESS": "Password updated successfully",
325 325 "PASSWORD_UPDATE_FAILED": "Password update failed",
326 326 "SUBSCRIPTION_EXPIRATION_MESSAGE": "Your license has been expired since ",
327   - "LICENSE_INACTIVE_MESSAGE": "Your license is inactive."
  327 + "LICENSE_INACTIVE_MESSAGE": "Your license is inactive.",
  328 + "INVALID_USER": "Invalid UserID"
328 329 //"ERROR_IN_FECTHING_DETAILS": "Error in fecthing details.",
329 330 //"MAIL_NOT_SENT": "Mail not sent."
330 331  
... ...