public static Response LoginFailedCheck(string user_name, string ipAddress) { var refId = DateTime.UtcNow.Ticks.ToString(); var logId = SmtpProvider.Info(refId, "LoginFailedCheck", "Update on login failure", "LoginFailedCheck", "LoginFailedCheck", ""); try { var MsgReponse = RegistrationContext.LoginFailedCheck(user_name); string[] res = null; res = MsgReponse.Split('|'); string msgNo = res[0]; RegisteredUser user = new RegisteredUser(); user = RegistrationContext.GetUserInfo(user_name); if (msgNo == "M") { SendInvalidLoginMail(user, ipAddress); } else if (msgNo == "OB" || msgNo == "B") { if (user != null) { SendBlockedMail(user, ipAddress); } } return(new Response() { IsValid = true, ErrorCode = ErrorProvider.ErrorCode.Success.ToString(), ErrorMessage = MsgReponse }); } catch (SqlException sqex) { RegisteredUser user = new RegisteredUser() { Username = user_name, Registration_ip = ipAddress }; SmtpProvider.Error <RegisteredUser, string>(sqex, "", refId, "LoginFailedCheck", "Update on login failure", "LoginFailedCheck", sqex.Message, user, "", "999", logId); return(new Response() { IsValid = false, ErrorCode = ErrorProvider.ErrorCode.Failure.ToString(), ErrorMessage = sqex.ToString() }); } catch (Exception ex) { RegisteredUser user = new RegisteredUser() { Username = user_name, Registration_ip = ipAddress }; SmtpProvider.Error <RegisteredUser, string>(ex, "", refId, "LoginFailedCheck", "Update on login failure", "LoginFailedCheck", ex.Message, user, "", "999", logId); return(new Response() { IsValid = false, ErrorCode = ErrorProvider.ErrorCode.Failure.ToString(), ErrorMessage = ex.ToString() }); } }
//public static string token; public static LoginCheckPointModel LoginCheckPoint(string user_name, string ip_address, bool isFirst, string type) { var refId = DateTime.UtcNow.Ticks.ToString(); var logId = SmtpProvider.Info(refId, "LoginCheckPoint", "Update on login success", "LoginCheckPoint", "LoginCheckPoint", ""); //var Country = ClsFunction.GetLocationFromIP(ip_address); string ip_country = type; string r_token = ""; try { var MsgReponse = RegistrationContext.LoginCheckPoint(user_name, ip_address, ip_country); if (MsgReponse.Split('|')[0] == "IP") { if (isFirst) { long Datetimenow = DateTime.UtcNow.ToFileTimeUtc(); RegisteredUser regUser = new RegisteredUser(); regUser = RegistrationContext.GetUserDetails(user_name); string t = regUser.RegistereduserId.ToString() + Guid.NewGuid().ToString(); r_token = ClsFunction.GenerateResetToken(t + ":" + Datetimenow); SendLogincheckpointMail(regUser, ip_address, r_token); } MsgReponse = "S|Success"; } return(new LoginCheckPointModel() { IsValid = true, ErrorCode = ErrorProvider.ErrorCode.Success.ToString(), ErrorMessage = MsgReponse, token = r_token }); } catch (SqlException sqex) { RegisteredUser user = new RegisteredUser() { Username = user_name, Registration_ip = ip_address }; SmtpProvider.Error <RegisteredUser, string>(sqex, "", refId, "LoginCheckPoint", "Update on login success", "LoginCheckPoint", sqex.Message, user, "", "999", logId); return(new LoginCheckPointModel() { IsValid = false, ErrorCode = ErrorProvider.ErrorCode.Failure.ToString(), ErrorMessage = "F|Failed", token = "" }); } catch (Exception ex) { RegisteredUser user = new RegisteredUser() { Username = user_name, Registration_ip = ip_address }; SmtpProvider.Error <RegisteredUser, string>(ex, "", refId, "LoginCheckPoint", "Update on login success", "LoginCheckPoint", ex.Message, user, "", "999", logId); return(new LoginCheckPointModel() { IsValid = false, ErrorCode = ErrorProvider.ErrorCode.Failure.ToString(), ErrorMessage = "F|Failed", token = "" }); } }