public ActionResult UserLogin([FromBody] AuthenticationModel authenticationModel) { _logger.LogInformation("POST: api/User/UserLogin Invoke"); ResponseModel responseModel = new ResponseModel(); string message = ""; authenticationModel.Password = EncryptionDecryptionHelper.EncryptString(authenticationModel.Password); var result = _userService.UserLogin(authenticationModel, message); if (result.Item1 == null) { responseModel.IsSuccess = false; responseModel.Message = result.Item2; } else if (result.Item2 == "User can login") { if (result.Item1.RoleId != 5) { if (result.Item1.ProfilePhoto != null) { result.Item1.ProfilePhoto = $"{baseUsrl}/{folderLocation}/{result.Item1.UserId}/{result.Item1.ProfilePhoto}"; } } responseModel.Result = result.Item1; responseModel.Message = result.Item2; } else { responseModel.Result = result.Item1; responseModel.Message = result.Item2; } return(Ok(responseModel)); }
// GET: /[email protected] public IHttpActionResult Get(string email) { IEnumerable <string> list; if (!Request.Headers.TryGetValues("x-token", out list)) { return(BadRequest("Un-authorized.")); } var token = list.FirstOrDefault(); if (string.IsNullOrWhiteSpace(token) || EncryptionDecryptionHelper.Decrypt(token) != ConfigurationManager.AppSettings["matchingKey"]) { return(BadRequest("Un-authorized.")); } var maxRetryAttempts = 8; var pauseBetweenFailures = TimeSpan.FromSeconds(2); Console.WriteLine("Starting application.. "); IList <DistributionListModel> distributionList = null; RetryHelper.RetryOnException(maxRetryAttempts, pauseBetweenFailures, () => { distributionList = new List <DistributionListModel>(); ExpandDistributionLists(10, email, distributionList); }); Console.WriteLine("Ending application.. "); return(Ok(distributionList)); }
public ActionResult PostUser(User user) { _logger.LogInformation("POST: api/User/PostUser Invoke"); user.Password = RandomPassword.RandomGeneratePassword(); user.Password = EncryptionDecryptionHelper.EncryptString(user.Password); ResponseModel responseModel = new ResponseModel(); var result = _userService.PostUser(user, _hostingEnvironment.ContentRootPath.ToString(), folderLocation); if (result == null) { responseModel.IsSuccess = false; responseModel.Message = "Record Not Created"; } else { EmailServiceHelper emailService = new EmailServiceHelper(_config, _email); //Azure SendGrid Email Grid if (_isSendMailBySendGrid) { emailService.AdminRegMessage(result).Wait(); } ////local Send Email Grid //if (!_isSendMailBySendGrid) // emailService.localUserRegMessage(result); responseModel.Result = result; } return(Ok(responseModel)); }
public void TryIfAssetDecryptableTestDirectoryNotFound() { string filePath = @"C:\OxigenIIData\Assets1\advert1100.jpg"; string password = "******"; bool actual = EncryptionDecryptionHelper.TryIfFileDecryptable(filePath, password); Assert.Fail("Expected exception not thrown"); }
public void TryIfAssetDecryptableTestWrongPassword() { string filePath = @"C:\OxigenIIData\Assets\advert1100.jpg"; string password = "******"; bool expected = false; bool actual = EncryptionDecryptionHelper.TryIfFileDecryptable(filePath, password); Assert.AreEqual(expected, actual); }
public void TryIfAssetDecryptableTestFileNotFound() { string filePath = @"C:\OxigenIIData\Assets\fgwruiowhegi.jpg"; string password = "******"; bool expected = false; bool actual = EncryptionDecryptionHelper.TryIfFileDecryptable(filePath, password); Assert.AreEqual(expected, actual); }
public void TryIfAssetDecryptableTest() { string filePath = string.Empty; string password = string.Empty; bool expected = false; bool actual; actual = EncryptionDecryptionHelper.TryIfFileDecryptable(filePath, password); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public ActionResult IsActiveUser(string UserId) { UserId = (UserId.Replace("œ", "+").Replace("Ž", "=").Replace("ô", "/")); UserId = EncryptionDecryptionHelper.DecryptString(UserId); _logger.LogInformation("GET: api/User/IsActiveUser Invoke"); ResponseModel responseModel = new ResponseModel(); int UserIdint = Convert.ToInt32(UserId); var result = _userService.IsActiveUser(UserIdint); responseModel.Result = result; return(Ok(responseModel)); }
public ActionResult ChangePassword(ChangePassword changePassword) { changePassword.Password = EncryptionDecryptionHelper.EncryptString(changePassword.Password); changePassword.OldPassword = EncryptionDecryptionHelper.EncryptString(changePassword.OldPassword); _logger.LogInformation("GET: api/User/GetUsersByRole/Id Invoke"); ResponseModel responseModel = new ResponseModel(); var result = _userService.ChangePassword(changePassword); if (result == "Old Password Is Not Correct") { responseModel.IsSuccess = false; responseModel.Message = "Old Password Is Not Correct"; } else { responseModel.Result = result; } return(Ok(responseModel)); }
public ActionResult GetUserByEncryptedId(string UserId) { string pswd = (UserId.Replace("œ", "+").Replace("Ž", "=").Replace("ô", "/")); var userId = Convert.ToInt32(EncryptionDecryptionHelper.DecryptString(pswd)); _logger.LogInformation("GET: api/User/GetUserByEncryptedId Invoke"); ResponseModel responseModel = new ResponseModel(); var result = _userService.GetUserById(userId); if (result == null) { responseModel.IsSuccess = false; responseModel.Message = "No Record Found"; } else { responseModel.Result = result; } return(Ok(responseModel)); }
public ActionResult Updatepassword(Forgotpassword forgotpassword) { string UserId = (forgotpassword.UserId.Replace("œ", "+").Replace("Ž", "=").Replace("ô", "/")); forgotpassword.UserId = EncryptionDecryptionHelper.DecryptString(UserId); forgotpassword.Password = EncryptionDecryptionHelper.EncryptString(forgotpassword.Password); _logger.LogInformation("Post: api/MobileUser/Updatepassword Invoke"); ResponseModel responseModel = new ResponseModel(); var result = _userService.Updatepassword(forgotpassword); if (result <= 0) { responseModel.IsSuccess = false; responseModel.Message = "Record Not Updated"; } else { responseModel.Result = "Update"; } return(Ok(responseModel)); }
public ActionResult ConfirmCounsellor([FromBody] JObject cofirm) { var userId = Convert.ToInt32(cofirm["id"].ToString()); var password = cofirm["pswd"].ToString(); var encriptedPassword = EncryptionDecryptionHelper.EncryptString(password); _logger.LogInformation("Post: api/User/ConfirmCounsellor Invoke"); ResponseModel responseModel = new ResponseModel(); var result = _userService.ConfirmCounsellor(userId, encriptedPassword); if (result != null) { //email responseModel.Message = "Success"; responseModel.Result = result; } else { responseModel.Message = $"User Not Exists"; responseModel.Result = result; } return(Ok(responseModel)); }
public ActionResult CheckUrlisExpireOrNot(string UserId, string GUID) { _logger.LogInformation("Post: api/User/UpdateUserIs Invoke"); ResponseModel responseModel = new ResponseModel(); UserId = (UserId.Replace("œ", "+").Replace("Ž", "=").Replace("ô", "/")); UserId = EncryptionDecryptionHelper.DecryptString(UserId); GUID = (GUID.Replace("œ", "+").Replace("Ž", "=").Replace("ô", "/")); GUID = EncryptionDecryptionHelper.DecryptString(GUID); int UserIdinInt = Convert.ToInt32(UserId); var result = _userService.CheckUrlisExpireOrNot(UserIdinInt, GUID); if (result == null) { responseModel.IsSuccess = false; responseModel.Message = "Record Not Updated"; } else { responseModel.Message = result; } return(Ok(responseModel)); }
// GET: /string public string GetToken(string inputStr) { return(EncryptionDecryptionHelper.Encrypt(inputStr)); }