public static Boolean InsertUpdateSignOnLog(clsSignOnLog objSignOnLog) { bool isAdded = false; string SpName = "usp_InsertUpdateSignOnLog"; try { using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { db.Execute(SpName, objSignOnLog, commandType: CommandType.StoredProcedure); } isAdded = true; } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } return(isAdded); }
public static clsSignOnLog SelectSignOnLogById(int?SigninId) { clsSignOnLog objSignOnLog = new clsSignOnLog(); bool isnull = true; string SpName = "usp_SelectSignOnLog"; var objPar = new DynamicParameters(); if (String.IsNullOrEmpty(SigninId.ToString())) { throw new ArgumentException("Function parameters cannot be blank!"); } else { try { objPar.Add("@SigninId", SigninId, dbType: DbType.Int32); using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { objSignOnLog = db.Query <clsSignOnLog>(SpName, objPar, commandType: CommandType.StoredProcedure).SingleOrDefault(); isnull = false; } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } } if (isnull) { return(null); } else { return(objSignOnLog); } }
public static string Login(string strEmail, string strPass) { CryptoJS objcryptoJS = new CryptoJS(); bool PassCheck = false; string _Error = string.Empty; clsUser objEmp = new clsUser(); strEmail = objcryptoJS.AES_decrypt(HttpUtility.UrlEncode(strEmail), AppConstants.secretKey, AppConstants.initVec).ToString(); strPass = objcryptoJS.AES_decrypt(HttpUtility.UrlEncode(strPass), AppConstants.secretKey, AppConstants.initVec).ToString(); if (GlobalMethods.IsEmail(strEmail)) { List <clsUser> lstUser = new List <clsUser>(); lstUser = UserDAL.SelectDynamicUser("EmailId like '" + strEmail + "'", "AuthorisedUserId"); if (lstUser != null) { if (lstUser.Count > 0) { PassCheck = SecurityObj.SecurityObj.VerifyHash(strPass, "SHA1", lstUser[0].Password, lstUser[0].salt); if (!PassCheck) { #region The Username or Password is bad! _Error = "Username or Password is not valid!"; #endregion } else { #region Creating all the User related sessions. HttpContext.Current.Session["UserAuthId"] = lstUser[0].AuthorisedUserId; if (GlobalMethods.ValueIsNull(lstUser[0].IsAdmin) != null) { if (lstUser[0].IsAdmin == 1) { HttpContext.Current.Session["IsAdmin"] = "1"; } } #endregion #region This is a valid account now transfer to a valid location. if (lstUser[0].IsActive == 1) { if (lstUser[0].EmailId == "*****@*****.**") { #region This is when AdminAdmin account is accessed for the first time. // HttpContext.Current.Response.Redirect(AppConstants.ConstAppURL + "AdminReset.aspx"); #endregion } else { clsSignOnLog objSOL = new clsSignOnLog(); objSOL.AuthorisedUserId = lstUser[0].AuthorisedUserId; objSOL.SignedOn = DateTime.Now; if (!SignOnLogDAL.InsertSignOnLog(objSOL)) { } #region This is when everything works as normal. Let the user log's in to the System. //HttpContext.Current.Response.Redirect(AppConstants.ConstAppURL + "dashboard.aspx?Dash=active"); _Error = AppConstants.ConstAppURL + "dashboard.aspx?Dash=active"; #endregion } } else if (lstUser[0].IsActive == -1) { #region This is when the account is disabled. _Error = "Currently, your account has been disabled. Please, email " + AppConstants.ConstHelpEmail + " or call " + AppConstants.ConstHelpPhone + "."; #endregion } else if (lstUser[0].IsActive == -2) { #region This is where we let the new user create a new password for a first time user. // HttpContext.Current.Response.Redirect(AppConstants.ConstAppURL + "ResetPassword.aspx"); _Error = AppConstants.ConstAppURL + "ResetPassword.aspx#login"; #endregion } else if (lstUser[0].IsActive == 0) { #region This is when the account is reset if the forgot password. //HttpContext.Current.Response.Redirect(AppConstants.ConstAppURL + "ResetPassword.aspx"); _Error = AppConstants.ConstAppURL + "ResetPassword.aspx#login"; #endregion } #endregion } } else { #region The Username or Password is bad! _Error = "Username or Password is not valid!"; #endregion } } else { #region The Username or Password is bad! _Error = "Username or Password is not valid!"; #endregion } } else { #region The Username or Password is bad! _Error = "Username or Password is not valid!"; #endregion } return(_Error); }