public void Login()
 {
     try
     {
         lblErrMsg.Visible = false;
         string Auth = UserLoginDetails.Get_UserLogin(txtuser.Text.Trim(), txtpwd.Text.Trim());
         if (Auth != "0")
         {
             Session["UserName"]           = txtuser.Text.Trim();
             Session["ChetanaCompanyName"] = ddlChetanaCompanyName.SelectedValue.ToLower();
             Session["Role"]     = Auth;
             Session["FY_Text"]  = ddlFinancialYear.SelectedItem.Text.Trim();
             Session["FY"]       = ddlFinancialYear.SelectedValue.Trim();
             Session["FromDate"] = "01/04/" + ddlFinancialYear.SelectedItem.Text.Trim().Substring(0, 4);
             Session["ToDate"]   = "30/03/" + ddlFinancialYear.SelectedItem.Text.Trim().Substring(5, 4);
             fillSessionZones(Session["UserName"].ToString());
             SetLogoutTime();
             Response.Redirect("Dashboard.aspx");
         }
         else
         {
             lblErrMsg.Visible   = true;
             lblErrMsg.ForeColor = System.Drawing.Color.Red;
             lblErrMsg.Text      = "Login Failed or User is blocked";
         }
     }
     catch (Exception ex)
     {
     }
 }
        public UserLoginDetails UserLogin(string UserId, string Password)
        {
            DataSet ds = _Apdal.UserLogin(UserId, Password);

            UserLoginDetails ud = new UserLoginDetails();

            if (ds != null && ds.Tables[0] != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        ud.Name            = ds.Tables[0].Rows[i]["FName"].ToString() + " " + ds.Tables[0].Rows[i]["LName"].ToString();
                        ud.MobileNO        = ds.Tables[0].Rows[i]["MobileNo"].ToString();
                        ud.RoleId          = Convert.ToInt32(ds.Tables[0].Rows[i]["RoleId"].ToString());
                        ud.UserID          = Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"].ToString());
                        ud.UserName        = ds.Tables[0].Rows[i]["UserName"].ToString();
                        ud.OzontelapiKey   = ds.Tables[0].Rows[i]["OzontelapiKey"].ToString();
                        ud.OzonteluserName = ds.Tables[0].Rows[i]["OzonteluserName"].ToString();
                        ud.Ozonteldid      = ds.Tables[0].Rows[i]["Ozonteldid"].ToString();
                        ud.AppVersionCode  = ds.Tables[0].Rows[i]["appVersionCode"].ToString();
                    }
                }
            }
            return(ud);
        }
        public JsonResult Login(UserLoginDTO userLogin)
        {
            if (!Global.Cache.CheckEmailExists(userLogin.UserName))
            {
                return(GetJson(EN_ErrorCodes.IncorrectLogin));
            }
            //
            UserLoginDetails UserLoginDetails = _DL.User.Account.LoginDetails_ByEmail(userLogin.UserName);

            //
            if (HashHMACSHA1.CheckSaltedHash(userLogin.Password, UserLoginDetails.PasswordHash))
            {
                var user = _DL.User.Get.ByID(UserLoginDetails.UserID);
                // Set User
                CurrentUser = user;
                // Set Log In
                Global.Cache.SetLogIn(user.UserID);
                //
                return(GetJson(new
                {
                    FirstName = user.UserFirstName,
                    LastName = user.UserLastName,
                    UserID = user.UserID,
                    AvatarSmall = user.AvatarSmall,
                    AvatarBig = user.AvatarBig
                }));
            }
            else
            {
                return(GetJson(EN_ErrorCodes.IncorrectPassword));
            }
        }
        private bool ValidateRememberedLogin()
        {
            if (CookieExists(_settings.RememberMeCookieName))
            {
                try
                {
                    string           loginId      = Decrypt(CookieValue(_settings.RememberMeCookieName, ""), _settings.EncryptionKey);
                    UserLoginDetails loginDetails = new UserLoginDetails(Convert.ToInt64(loginId), true);
                    bool             loggedIn     = _loginProvider.Login(String.Empty, String.Empty, GetIpAddress(), 0, ref loginDetails) == LoginResult.Remembered;

                    if (loggedIn)
                    {
                        UserSession session = GetUserSession();

                        if (session != null)
                        {
                            session.Login(loginDetails.UserId, loginDetails.Username, loginDetails.Email);
                        }

                        GetAuthenticationService().SignInAsync(HttpContext,
                                                               nameof(AspNetCore.PluginManager),
                                                               new ClaimsPrincipal(_claimsProvider.GetUserClaims(loginDetails.UserId)),
                                                               _claimsProvider.GetAuthenticationProperties());
                    }

                    return(loggedIn);
                }
                catch
                {
                    CookieDelete(_settings.RememberMeCookieName);
                }
            }

            return(false);
        }
    public void CheckLogin(string userid, string Password, string companyname, string Year, string yearId)
    {
        try
        {
            lblErrMsg.Visible = false;
            string Auth = UserLoginDetails.Get_UserLogin(userid, Password);

            if (Auth != "0")
            {
                Session["UserName"]           = userid;
                Session["ChetanaCompanyName"] = companyname;
                Session["Role"]     = Auth;
                Session["FY_Text"]  = Year;
                Session["FY"]       = yearId;
                Session["FromDate"] = "01/04/" + Year.Substring(0, 4);
                Session["ToDate"]   = "30/03/" + Year.Substring(5, 4);
                SetLogoutTime();
                Response.Redirect("Dashboard.aspx");
            }
            else
            {
                lblErrMsg.Visible   = true;
                lblErrMsg.ForeColor = System.Drawing.Color.Red;
                lblErrMsg.Text      = "Login Failed or User is blocked";
            }
        }
        catch (Exception ex)
        {
        }
    }
        private Users AuthenticateUser(UserLoginDetails loginDetailsRequest)
        {
            Users userDetailsToReturnForAuthentication = null;

            // First step is to check if the username/email is in the databsae
            //var userDetails = BusinessLogicLayerFacade.Instance.Users_GetByUsername(loginDetailsRequest.Username);
            Users userDetails = null;

            if (userDetails != null)
            {
                // There is such a user grab the salted hashed string and generate the password and check if its right against the stored encryptedPassword in the database
                string passwordSaltInDatabase      = userDetails.EncryptionRandomSalt;
                string encryptedPasswordInDatabase = userDetails.EcryptedPassword;
                string applicationSecretSolt       = this._config["Jwt:ExtraApplicationPasswordsEncryptionInAdditionToRandomSalts"];

                bool arePasswordsEqualAfterHashAndEncryptions = CryptographyProcessor.ArePasswordsEqual(loginDetailsRequest.Password,
                                                                                                        encryptedPasswordInDatabase,
                                                                                                        passwordSaltInDatabase,
                                                                                                        applicationSecretSolt);

                if (!arePasswordsEqualAfterHashAndEncryptions)
                {
                    // Authentication failed! return "null" for current userDetails so Jwt token will not be created
                    userDetails = null;
                    userDetailsToReturnForAuthentication = null;
                }
                else
                {
                    // Authentication passed successfully -- return the current userDetails for Jwt token generation
                    userDetailsToReturnForAuthentication = userDetails;
                }
            }

            return(userDetailsToReturnForAuthentication);
        }
Beispiel #7
0
    protected void lnlpassword_Click(object sender, EventArgs e)
    {
        try
        {
            string empid = ((LinkButton)(sender)).CommandArgument;
            lblEID.Text = empid;
            UserLoginDetails _objuserlog = new UserLoginDetails();
            _objuserlog.EmpID = Convert.ToInt32(empid.ToString());
            string Isblock = ((LinkButton)(sender)).Text.ToLower();
            txtPassword.Attributes.Add("value", ((Label)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("lblPassword")).Text);
            ddlRolepop.DataSource = Roles();
            ddlRolepop.DataBind();
            ddlRolepop.Items.Insert(0, new ListItem("None", "0"));
            ddlRolepop.SelectedValue = ((DropDownList)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("ddlrole")).SelectedValue;
            ddlRolepop.Attributes.Add("style", "display:none;");
            selrol.Visible = false;

            txtPassword.Focus();
            txtPassword.Text  = ((Label)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("lblPassword")).Text;
            spnname.InnerHtml = ((Label)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("lblEName")).Text;
            UpdatePanel1.Update();
            ModalPopUpExMSG.Show();
        }
        catch
        {
        }
    }
        private async Task LoginUsingCookieValue(UserSession userSession, HttpContext context,
                                                 IAuthenticationService authenticationService)
        {
            using (StopWatchTimer stopwatchTimer = StopWatchTimer.Initialise(_autoLoginCookieTimings))
            {
                string cookieValue = CookieValue(context, _loginControllerSettings.RememberMeCookieName,
                                                 _loginControllerSettings.EncryptionKey, String.Empty);

                if (Int64.TryParse(cookieValue, out long userId))
                {
                    UserLoginDetails loginDetails = new UserLoginDetails(userId, true);

                    LoginResult loginResult = _loginProvider.Login(String.Empty, String.Empty,
                                                                   GetIpAddress(context), 1, ref loginDetails);

                    if (loginResult == LoginResult.Remembered)
                    {
                        userSession.Login(userId, loginDetails.Username, loginDetails.Email);
                        await authenticationService.SignInAsync(context,
                                                                _loginControllerSettings.AuthenticationScheme,
                                                                new ClaimsPrincipal(_claimsProvider.GetUserClaims(loginDetails.UserId)),
                                                                _claimsProvider.GetAuthenticationProperties());
                    }
                    else
                    {
                        CookieDelete(context, _loginControllerSettings.RememberMeCookieName);
                    }
                }
                else
                {
                    CookieDelete(context, _loginControllerSettings.RememberMeCookieName);
                }
            }
        }
Beispiel #9
0
        public UserLoginDetails GetUserlogInDetails(string userName, string passWord, int roleID)
        {
            try
            {
                var _reader = GetvalidUserdetails(userName, passWord, roleID);

                var _objUserLogindetails = new UserLoginDetails();

                while (_reader.Read())
                {
                    _objUserLogindetails.UserName = _reader["UserName"].ToString();
                    _objUserLogindetails.Password = _reader["Password"].ToString();
                    _objUserLogindetails.roleId   = Convert.ToInt16(_reader["UserRoleId"]);
                }
                return(_objUserLogindetails);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _studentDatabaseConnection.CloseSqlDatabaseConnection();
            }
        }
Beispiel #10
0
    protected void IsSystemAdmin_CheckedChanged(object sender, EventArgs e)
    {
        Label            lblEmpid             = (Label)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("lblEID");
        Label            lblEmpName           = (Label)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("lblEName");
        DropDownList     ddl                  = (DropDownList)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("ddlrole");
        Label            lblPassword          = (Label)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("lblPassword");
        UserLoginDetails _objUsreLoginDetails = new UserLoginDetails();

        _objUsreLoginDetails.EmpID    = Convert.ToInt32(lblEmpid.Text);
        _objUsreLoginDetails.RoleID   = Convert.ToInt32(ddl.SelectedValue);
        _objUsreLoginDetails.Password = lblPassword.Text.Trim();
        _objUsreLoginDetails.IsActive = true;
        if (((CheckBox)((System.Web.UI.WebControls.WebControl)(sender))).Checked == false)
        {
            _objUsreLoginDetails.IsSysAdmin = false;
        }
        else
        {
            _objUsreLoginDetails.IsSysAdmin = true;
        }
        _objUsreLoginDetails.Save();
        BindDataEmployeeDetails();
        upPanel.Update();
        loder(ddl.SelectedItem.Text + " role succcessfully set to " + lblEmpName.Text, "4000");
    }
        private bool ValidateRememberedLogin()
        {
            if (CookieExists(_settings.RememberMeCookieName))
            {
                try
                {
                    string           loginId      = Decrypt(CookieValue(_settings.RememberMeCookieName, ""), _settings.EncryptionKey);
                    UserLoginDetails loginDetails = new UserLoginDetails(Convert.ToInt64(loginId), true);
                    bool             loggedIn     = _loginProvider.Login(String.Empty, String.Empty, GetIpAddress(), 0, ref loginDetails) == LoginResult.Remembered;

                    if (loggedIn)
                    {
                        UserSession session = GetUserSession();

                        if (session != null)
                        {
                            session.Login(loginDetails.UserId, loginDetails.Username, loginDetails.Email);
                        }
                    }

                    return(loggedIn);
                }
                catch
                {
                }
            }

            return(false);
        }
Beispiel #12
0
        public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            UserLoginDetails user = AutofacWebapiConfig.ResolveRequestInstance <IUOWUsers>().AuthenticateAndFetchUserDetail(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "The user name or password is incorrect");
                return(Task.FromResult <object>(null));
            }
            var identity = new ClaimsIdentity("JWT");

            identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
            identity.AddClaim(new Claim("userid", user.UserDetailID.ToString()));
            identity.AddClaim(new Claim("Username", user.Username));
            var props = new AuthenticationProperties(new Dictionary <string, string>()
            {
                { "audience", context.ClientId ?? string.Empty },
                { "name", user.Name },
                { "lastlogin", user.LastLogin.HasValue ? Convert.ToString(user.LastLogin.Value) : string.Empty }
            });
            var ticket = new AuthenticationTicket(identity, props);

            context.Validated(ticket);
            return(Task.FromResult <object>(null));
        }
        public IActionResult Index(LoginViewModel model)
        {
            LoginCacheItem loginCacheItem = GetCachedLoginAttempt(true);

            if (!String.IsNullOrEmpty(loginCacheItem.CaptchaText))
            {
                if (!loginCacheItem.CaptchaText.Equals(model.CaptchaText))
                {
                    ModelState.AddModelError(String.Empty, "Invalid Validation Code");
                }
            }

            loginCacheItem.LoginAttempts++;

            model.ShowCaptchaImage = loginCacheItem.LoginAttempts >= _settings.CaptchaShowFailCount;

            UserLoginDetails loginDetails = new UserLoginDetails();

            switch (_loginProvider.Login(model.Username, model.Password, GetIpAddress(),
                                         loginCacheItem.LoginAttempts, ref loginDetails))
            {
            case LoginResult.Success:
                RemoveLoginAttempt();

                UserSession session = GetUserSession();

                if (session != null)
                {
                    session.Login(loginDetails.UserId, loginDetails.Username, loginDetails.Email);
                }

                if (model.RememberMe)
                {
                    CookieAdd(_settings.RememberMeCookieName, Encrypt(loginDetails.UserId.ToString(), _settings.EncryptionKey), _settings.LoginDays);
                }

                return(Redirect(model.ReturnUrl));

            case LoginResult.AccountLocked:
                return(RedirectToAction("AccountLocked", new { username = model.Username }));

            case LoginResult.PasswordChangeRequired:
                return(Redirect(_settings.ChangePasswordUrl));

            case LoginResult.InvalidCredentials:
                ModelState.AddModelError(String.Empty, "Invalid username or password");
                break;
            }

            if (model.ShowCaptchaImage)
            {
                loginCacheItem.CaptchaText = GetRandomWord(_settings.CaptchaWordLength, CaptchaCharacters);
            }

            return(View(model));
        }
        public void LoginProvider_ValidLogon_PasswordChangeRequired()
        {
            ILoginProvider loginProvider = new MockLoginProvider();

            UserLoginDetails userLoginDetails = new UserLoginDetails();
            LoginResult      loginResult      = loginProvider.Login("admin", "changepassword", "::1", 0, ref userLoginDetails);

            Assert.AreEqual(LoginResult.PasswordChangeRequired, loginResult);
            Assert.AreEqual(124, userLoginDetails.UserId);
        }
        /// <summary>
        /// This is login method and it will connect to DB and check if user is exists or not. If user exists then it will display the user detail
        /// </summary>
        /// <param name="userLogin"></param>
        /// <returns></returns>
        public MDTTransactionInfo Login(UserLogin userLogin)
        {
            MDTTransactionInfo  mdt          = new MDTTransactionInfo();
            UserLoginDetails    loginDetails = null;
            List <SqlParameter> prm          = new List <SqlParameter>();
            SqlParameter        email        = new SqlParameter("@email", userLogin.UserName);

            prm.Add(email);
            SqlParameter pwd = new SqlParameter("@pwd", userLogin.Password);

            prm.Add(pwd);

            SqlParameter status = new SqlParameter("@Status", 0);

            status.Direction = ParameterDirection.Output;
            prm.Add(status);

            DataTable dt = DatabaseSettings.GetDataSet("sp_LoginUser", out APIHelper.StatusValue, prm).Tables[0];

            if (APIHelper.StatusValue == 1)
            {
                if (dt.Rows.Count > 0)
                {
                    loginDetails                = new UserLoginDetails();
                    loginDetails.USER_ID        = Convert.ToInt32(dt.Rows[0]["USER_ID"]);
                    loginDetails.FIRST_NAME     = dt.Rows[0]["FIRST_NAME"].ToString();
                    loginDetails.LAST_NAME      = dt.Rows[0]["LAST_NAME"].ToString();
                    loginDetails.EMAIL_ADDRESS  = dt.Rows[0]["EMAIL_ADDRESS"].ToString();
                    loginDetails.FORCE_PWD_CHNG = Convert.ToBoolean(dt.Rows[0]["FORCE_PWD_CHNG"]);
                    loginDetails.PHOTO          = dt.Rows[0]["PHOTO"].ToString();
                    loginDetails.ROLE_NAME      = dt.Rows[0]["ROLE_NAME"].ToString();
                    loginDetails.ROLE_ID        = Convert.ToInt32(dt.Rows[0]["ROLE_ID"]);
                }
                mdt.status            = HttpStatusCode.OK;
                mdt.transactionObject = loginDetails;
                mdt.msgCode           = MessageCode.Success;
                mdt.message           = "Login Successfully";
            }
            else if (APIHelper.StatusValue == 5)
            {
                ErrorInfoFromSQL eInfo = null;
                if (dt.Rows.Count > 0)
                {
                    eInfo                 = new ErrorInfoFromSQL();
                    eInfo                 = DatabaseSettings.GetError(dt);
                    mdt.status            = HttpStatusCode.BadRequest;
                    mdt.transactionObject = eInfo;
                    mdt.msgCode           = (eInfo.Status == 1) ? MessageCode.Success : MessageCode.Failed;
                    mdt.message           = eInfo.ErrorMessage;
                    mdt.LineNumber        = eInfo.ErrorLineNo;
                    mdt.ProcedureName     = eInfo.Procedure;
                }
            }
            return(mdt);
        }
    public void fillSessionZones(string EmpCode)
    {
        DataTable dt = new DataTable();

        dt = UserLoginDetails.Get_UserLoginDetails(EmpCode);
        if (dt.Rows.Count > 0)
        {
            Session["zoneLevel"] = dt.Rows[0][0].ToString();
            Session["zoneId"]    = dt.Rows[0][1].ToString();
        }
    }
        private async Task <bool> LoginUsingBasicAuth(UserSession userSession, HttpContext context,
                                                      IAuthenticationService authenticationService)
        {
            using (StopWatchTimer stopWatchTimer = StopWatchTimer.Initialise(_autoLoginBasicAuthLogin))
            {
                string authData = context.Request.Headers[SharedPluginFeatures.Constants.HeaderAuthorizationName];

                if (!authData.StartsWith("Basic ", StringComparison.InvariantCultureIgnoreCase))
                {
                    context.Response.StatusCode = 400;
                    return(false);
                }

                try
                {
                    authData = System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(Convert.FromBase64String(authData.Substring(6)));
                }
                catch (FormatException)
                {
                    context.Response.StatusCode = 400;
                    return(false);
                }

                string[] authParts = authData.Split(':', StringSplitOptions.RemoveEmptyEntries);

                if (authParts.Length != 2)
                {
                    context.Response.StatusCode = 400;
                    return(false);
                }

                UserLoginDetails loginDetails = new UserLoginDetails();

                LoginResult loginResult = _loginProvider.Login(authParts[0], authParts[1],
                                                               GetIpAddress(context), 1, ref loginDetails);

                if (loginResult == LoginResult.Success)
                {
                    userSession.Login(loginDetails.UserId, loginDetails.Username, loginDetails.Email);
                    await authenticationService.SignInAsync(context,
                                                            _loginControllerSettings.AuthenticationScheme,
                                                            new ClaimsPrincipal(_claimsProvider.GetUserClaims(loginDetails.UserId)),
                                                            _claimsProvider.GetAuthenticationProperties());

                    return(true);
                }
                else
                {
                    context.Response.StatusCode = 401;
                    return(false);
                }
            }
        }
 public HttpResponseMessage UserLogin(UserLoginDetails loginDetails)
 {
     try
     {
         UserRegistrationController userlogin = new UserRegistrationController();
         string Response = userlogin.Login(loginDetails);
         return(Request.CreateResponse(HttpStatusCode.OK, Response));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
        public IActionResult Login([FromBody] UserLoginDetails loginDetailsRequest)
        {
            IActionResult response = Unauthorized();
            var           user     = AuthenticateUser(loginDetailsRequest);

            if (user != null)
            {
                var tokenString = GenerateJSONWebToken(user);
                response = Ok(new { token = tokenString });
            }

            return(response);
        }
Beispiel #20
0
    public void Login()
    {
        try
        {
            lblErrMsg.Visible = false;
            string Auth = UserLoginDetails.Get_UserLogin(txtuser.Text.Trim(), txtpwd.Text.Trim());

            if (Auth != "0")
            {
                Session["UserName"]           = txtuser.Text.Trim();
                Session["ChetanaCompanyName"] = ddlChetanaCompanyName.SelectedValue.ToLower();
                Session["Role"]     = Auth;
                Session["FY_Text"]  = ddlFinancialYear.SelectedItem.Text.Trim();
                Session["FY"]       = ddlFinancialYear.SelectedValue.Trim();
                Session["FromDate"] = "01/04/" + ddlFinancialYear.SelectedItem.Text.Trim().Substring(0, 4);
                Session["ToDate"]   = "31/03/" + ddlFinancialYear.SelectedItem.Text.Trim().Substring(5, 4);
                fillSessionZones(Session["UserName"].ToString());

                SetLogoutTime();
                dostoreSelectYear();

                // Get initial data
                Session["AuditCutOffDate"] = null;

                DataSet ds = OtherClass.GetInitialData("", "", "", "", "", "init", Convert.ToInt32(Session["FY"]));

                if (ds != null)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        Session["AuditCutOffDate"] = Convert.ToDateTime(dr[0].ToString()).ToString("dd-MM-yyyy");
                    }
                }


                Response.Redirect("Dashboard.aspx");
            }
            else
            {
                lblErrMsg.Visible   = true;
                lblErrMsg.ForeColor = System.Drawing.Color.Red;
                lblErrMsg.Text      = "Login Failed or User is blocked";
            }
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #21
0
    protected void btnLink_Click(object sender, EventArgs e)
    {
        try
        {
            string           empid       = ((LinkButton)(sender)).CommandArgument;
            UserLoginDetails _objuserlog = new UserLoginDetails();
            _objuserlog.EmpID = Convert.ToInt32(empid.ToString());

            string Isblock = ((LinkButton)(sender)).Text.ToLower();
            if (Isblock == "block")
            {
                _objuserlog.IsBlocked = true;
                _objuserlog.Update_UserLog();
                _objuserlog.Update_UserLog();
                BindDataEmployeeDetails();
                loder("succcessfully block", "4000");
            }
            else

            if (Isblock == "unblock")
            {
                _objuserlog.IsBlocked = false;
                _objuserlog.Update_UserLog();
                _objuserlog.Update_UserLog();
                BindDataEmployeeDetails();
                loder("succcessfully unblock", "4000");
            }
            else
            {
                lblEID.Text           = empid;
                ddlRolepop.DataSource = Roles();
                ddlRolepop.DataBind();
                ddlRolepop.Attributes.Add("style", "display:block;");
                selrol.Visible = true;
                ddlRolepop.Items.Insert(0, new ListItem("None", "0"));
                txtPassword.Focus();
                txtPassword.Text = "";
                txtPassword.Attributes.Add("value", "");
                txtPassword.Text = ((Label)((System.Web.UI.WebControls.WebControl)(sender)).Parent.FindControl("lblEName")).Text;

                UpdatePanel1.Update();
                ModalPopUpExMSG.Show();
            }
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #22
0
        public ActionResult Login(UserLoginViewModel ViewModel, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                DAL.Users.UserDAL UserDALObj = new DAL.Users.UserDAL();
                //var user = await UserManager.FindAsync(model.UserName, model.Password);
                UserLoginDetails User = UserDALObj.MatchUserCredentials(ViewModel.EmailID, ViewModel.Password); //Membership.ValidateUser(model.UserName, model.Password);
                if (User != null)
                {
                    if (User.IsApproved == null)
                    {
                        ModelState.AddModelError("", "Your account approval is still pending. Please contact to your admin for instant approval.");
                    }
                    else if (!User.IsApproved.Value)
                    {
                        ModelState.AddModelError("", "Your account hase been rejected. Please contact customer support for more information.");
                    }
                    else
                    {
                        Common.Props.LoginUser = User;

                        JavaScriptSerializer js          = new JavaScriptSerializer();
                        string data                      = js.Serialize(User);
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, User.FullName, DateTime.Now, DateTime.Now.AddMonths(1), ViewModel.RememberMe, data);
                        string     encToken              = FormsAuthentication.Encrypt(ticket);
                        HttpCookie authoCookies          = new HttpCookie(FormsAuthentication.FormsCookieName, encToken);
                        Response.Cookies.Add(authoCookies);
                        //await SignInAsync(user, model.RememberMe);
                        if (Url.IsLocalUrl(returnUrl))
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Invalid username or password.");
                }
            }

            // If we got this far, something failed, redisplay form
            ModelState.Remove("Password");
            return(View(ViewModel));
        }
Beispiel #23
0
 public ActionResult LogIn(UserLoginDetails loginDetails)
 {
     if (!ModelState.IsValid)
     {
         return(View("LogIn", loginDetails));
     }
     if (!Membership.ValidateUser(loginDetails.Username, loginDetails.Password))
     {
         ModelState.AddModelError("UserOrPasswordNoValid", "The username or password you gave are not valid so we can't log you in.");
         return(View("LogIn", loginDetails));
     }
     _userActivities.UpdateLoggedInDateTime(loginDetails.Username);
     _userActivities.UpdateLastActionDateTime(loginDetails.Username);
     FormsAuthentication.SetAuthCookie(loginDetails.Username, true);
     return(RedirectToAction("Index", "Home"));
 }
        public async Task <IActionResult> Login(UserModel user)
        {
            if (ModelState.GetValidationState("Email") == ModelValidationState.Valid &&
                ModelState.GetFieldValidationState("Password") == ModelValidationState.Valid)
            {
                UserLoginDetails    details  = new UserLoginDetails(user);
                HttpResponseMessage response = await client.PostAsJsonAsync(FB_SignIn, details);

                try {
                    response.EnsureSuccessStatusCode();
                    var responseBody = await response.Content.ReadAsAsync <SuccessResponse>();

                    user.UserId        = responseBody.localId;
                    TempData["UserId"] = user.UserId;
                    TempData.Keep("UserID");

                    using (SqlConnection con = new SqlConnection(CS))
                    {
                        SqlCommand cmd = new SqlCommand("spUserTypeById", con);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@UserId", user.UserId);
                        con.Open();
                        SqlDataReader sdr = cmd.ExecuteReader();
                        while (sdr.Read())
                        {
                            string type = sdr["Type"].ToString();
                            if (type == "Admin")
                            {
                                TempData["UserId"] = user.UserId;
                                TempData.Keep("UserID");
                                TempData["SuccessMessage"] = "Successfully logged in";
                                return(RedirectToAction("Admin", "Admin"));
                            }
                        }
                    }
                    TempData["SuccessMessage"] = "Successfully logged in";
                    return(RedirectToAction("Index", "Home"));
                }
                catch (HttpRequestException e)
                {
                    TempData["ErrorMessage"] = "Something went wrong. Please try again later.";
                    return(RedirectToAction("Index", "Home"));
                }
            }
            TempData["ErrorMessage"] = "Something went wrong. Please try again later.";
            return(RedirectToAction("Index", "Home"));
        }
        public UserLoginDetails UserLogin(string apiKey, string UserId, string Password)
        {
            UserLoginDetails _userLD = new UserLoginDetails();

            if (apiKey == ConfigurationManager.AppSettings["reasonkey"])
            {
                try
                {
                    _userLD = _agentbal.UserLogin(UserId, Password);
                }
                catch (Exception ex)
                {
                    LogBal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0);
                }
            }
            return(_userLD);
        }
        public async Task <HttpResponseMessage> UserLogin(JObject userDetailsJson)
        {
            var task = await Task <HttpResponseMessage> .Factory.StartNew(() => {
                HttpResponseMessage response = null;
                UserLoginDetails userDetails = JsonConvert.DeserializeObject <UserLoginDetails>(userDetailsJson.ToString());
                if (DataAccess.DoesUserExists(userDetails))
                {
                    response = Request.CreateResponse(HttpStatusCode.OK, "User Login successfully");
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.NotFound, "User Not Found");
                }
                return(response);
            });

            return(task);
        }
Beispiel #27
0
        public async Task Invoke(HttpContext context)
        {
            using (StopWatchTimer stopwatchTimer = StopWatchTimer.Initialise(_loginTimings))
            {
                UserSession userSession = GetUserSession(context);

                if (userSession != null && String.IsNullOrEmpty(userSession.UserName) &&
                    CookieExists(context, _loginControllerSettings.RememberMeCookieName))
                {
                    using (StopWatchTimer stopwatchAutoLogin = StopWatchTimer.Initialise(_autoLoginTimings))
                    {
                        string cookieValue = CookieValue(context, _loginControllerSettings.RememberMeCookieName,
                                                         _loginControllerSettings.EncryptionKey, String.Empty);

                        if (Int64.TryParse(cookieValue, out long userId))
                        {
                            UserLoginDetails loginDetails = new UserLoginDetails(userId, true);

                            LoginResult loginResult = _loginProvider.Login(String.Empty, String.Empty,
                                                                           base.GetIpAddress(context), 1, ref loginDetails);

                            if (loginResult == LoginResult.Remembered)
                            {
                                userSession.Login(userId, loginDetails.Username, loginDetails.Email);
                                await _authenticationService.SignInAsync(context,
                                                                         _loginControllerSettings.AuthenticationScheme,
                                                                         new ClaimsPrincipal(_claimsProvider.GetUserClaims(loginDetails.UserId)),
                                                                         _claimsProvider.GetAuthenticationProperties());
                            }
                            else
                            {
                                CookieDelete(context, _loginControllerSettings.RememberMeCookieName);
                            }
                        }
                        else
                        {
                            CookieDelete(context, _loginControllerSettings.RememberMeCookieName);
                        }
                    }
                }
            }

            await _next(context);
        }
Beispiel #28
0
        protected void loginbtn_Click(object sender, EventArgs e)
        {
            try
            {
                UserLoginDetails userinfo = new UserLoginDetails();
                userinfo.UserName = userName.Text;
                userinfo.Password = password.Text;
                List <string> msg = obj.LoginUserDetails(userinfo).ToList();
                Label.Text = " Name = " + msg.ElementAt(0) + " Id = " + msg.ElementAt(1);

                Session["id"] = userName.Text;
                Response.Redirect("Sample.aspx");
                Session.RemoveAll();
            }
            catch (Exception ex)
            {
                Label.Text = "Wrong Id Or Password";
            }
        }
Beispiel #29
0
 protected void ddlrole_changed(object sender, EventArgs e)
 {
     try
     {
         Label            lblEmpid             = (Label)((System.Web.UI.WebControls.ListControl)(sender)).Parent.FindControl("lblEID");
         Label            lblEmpName           = (Label)((System.Web.UI.WebControls.ListControl)(sender)).Parent.FindControl("lblEName");
         DropDownList     ddl                  = (DropDownList)((System.Web.UI.WebControls.ListControl)(sender));
         Label            lblPassword          = (Label)((System.Web.UI.WebControls.ListControl)(sender)).Parent.FindControl("lblPassword");
         UserLoginDetails _objUsreLoginDetails = new UserLoginDetails();
         _objUsreLoginDetails.EmpID    = Convert.ToInt32(lblEmpid.Text);
         _objUsreLoginDetails.RoleID   = Convert.ToInt32(ddl.SelectedValue);
         _objUsreLoginDetails.Password = lblPassword.Text.Trim();
         _objUsreLoginDetails.IsActive = true;
         _objUsreLoginDetails.Save();
         loder(ddl.SelectedItem.Text + " role succcessfully set to " + lblEmpName.Text, "4000");
     }
     catch (Exception ex)
     {
         loder(ex.Message, "4000");
     }
 }
Beispiel #30
0
    protected void btnPasswordsave_Click(object sender, EventArgs e)
    {
        UserLoginDetails _objUsreLoginDetails = new UserLoginDetails();

        _objUsreLoginDetails.EmpID    = Convert.ToInt32(lblEID.Text);
        _objUsreLoginDetails.RoleID   = Convert.ToInt32(ddlRolepop.SelectedValue);
        _objUsreLoginDetails.Password = txtPassword.Text.Trim();
        _objUsreLoginDetails.IsActive = true;
        _objUsreLoginDetails.Save();
        BindDataEmployeeDetails();
        upPanel.Update();
        ModalPopUpExMSG.Hide();
        if (selrol.Visible == false)
        {
            loder("Password changed succcessfully", "4000");
        }
        else
        {
            loder("Login created succcessfully", "4000");
        }
    }