예제 #1
0
        public string UpdatePasswordUser(UsersModel model)
        {
            string          encryptedNewPassword = new EncryptDecrypt().EncryptText(model.NewPassword);
            string          encryptedOldPassword = new EncryptDecrypt().EncryptText(model.OldPassword);
            string          msg = "";
            long            uid = ShomaGroupWebSession.CurrentUser != null ? ShomaGroupWebSession.CurrentUser.UserID : 0;
            ShomaRMEntities db  = new ShomaRMEntities();

            var userNameExists = db.tbl_Login.Where(p => p.UserID == uid && p.Password == encryptedOldPassword).FirstOrDefault();


            if (userNameExists != null)
            {
                tbl_Login userData = new tbl_Login();

                userNameExists.Password = encryptedNewPassword;
                db.SaveChanges();
                msg = "Password Change Successfully";
            }
            else
            {
                msg = "Password / User Does Not Match with old";
            }
            return(msg);
        }
예제 #2
0
        private void click_AddUser(object sender, EventArgs e)
        {
            string userPassword = text_NewPassword.Text;

            if (ValidateNewUserEntry())
            {
                MessageBox.Show("Please enter detials in ALL fields");
            }
            else
            {
                MyDBEntities mde     = new MyDBEntities();
                tbl_Login    account = new tbl_Login()
                {
                    Username = text_NewUser.Text,
                    Password = BCrypt.Net.BCrypt.HashPassword(userPassword),
                    Name     = text_NewName.Text,
                    Email    = text_NewEmail.Text
                };
                mde.tbl_Login.Add(account);
                mde.SaveChanges();
                MessageBox.Show("Successful");

                NewUser.ActiveForm.Close();
            }
        }
예제 #3
0
        public IActionResult GetV1([FromRoute] string loginValue)
        {
            Guid      loginID;
            tbl_Login login = null;

            //check if identifier is guid. resolve to guid if not.
            if (Guid.TryParse(loginValue, out loginID))
            {
                login = uow.Logins.Get(x => x.Id == loginID)
                        .SingleOrDefault();
            }
            else
            {
                login = uow.Logins.Get(x => x.Name == loginValue)
                        .SingleOrDefault();
            }

            if (login == null)
            {
                ModelState.AddModelError(MessageType.LoginNotFound.ToString(), $"Login:{loginValue}");
                return(NotFound(ModelState));
            }

            return(Ok(map.Map <LoginV1>(login)));
        }
예제 #4
0
        public bool IsInLogin(tbl_User user, tbl_Login login)
        {
            if (_context.Set<tbl_UserLogin>()
                .Any(x => x.UserId == user.Id && x.LoginId == login.Id))
                return true;

            return false;
        }
        public bool EditUserRegistrationData(fetchingSpecificLoginData userUpdatedData)
        {
            bool      flag           = true;
            tbl_Login newUpdatedData = context.tbl_Login.Where(x => x.Sl_No == userUpdatedData.Sl_No).FirstOrDefault();

            newUpdatedData.UserPassword = userUpdatedData.UserPassword;
            context.SaveChanges();
            return(flag);
        }
예제 #6
0
        public int SaveUpdateUser(UsersModel model)
        {
            ShomaRMEntities db             = new ShomaRMEntities();
            var             userNameExists = db.tbl_Login.Where(p => p.UserID != model.UserID && p.Username == model.Username).FirstOrDefault();
            string          encpassword    = new EncryptDecrypt().EncryptText(model.Password);

            if (userNameExists == null)
            {
                if (model.UserID == 0)
                {
                    var userData = new tbl_Login()
                    {
                        FirstName = model.FirstName,
                        LastName  = model.LastName,

                        CellPhone   = model.CellPhone,
                        Email       = model.Email,
                        Username    = model.Username,
                        Password    = encpassword,
                        IsActive    = model.IsActive,
                        IsSuperUser = 0,
                        UserType    = model.UserType
                    };
                    db.tbl_Login.Add(userData);
                    db.SaveChanges();
                    model.UserID = userData.UserID;
                }
                else
                {
                    var userInfo = db.tbl_Login.Where(p => p.UserID == model.UserID).FirstOrDefault();
                    if (userInfo != null)
                    {
                        userInfo.FirstName = model.FirstName;
                        userInfo.LastName  = model.LastName;

                        userInfo.CellPhone = model.CellPhone;
                        userInfo.Email     = model.Email;

                        userInfo.Username = model.Username;
                        userInfo.Password = encpassword;
                        userInfo.IsActive = model.IsActive;
                        userInfo.UserType = model.UserType;
                        db.SaveChanges();
                    }
                    else
                    {
                        throw new Exception(model.Username + " not exists in the system.");
                    }
                }

                return(model.UserID);
            }
            else
            {
                throw new Exception(model.Username + " already exists in the system.");
            }
        }
        public void saveNewRegisterationData(RegisterNewUserViewModel registerNewUserViewModel)
        {
            tbl_Login saveNewRegistrationDataToDB = new tbl_Login();

            saveNewRegistrationDataToDB.UserID        = registerNewUserViewModel.UserEmail;
            saveNewRegistrationDataToDB.UserEmail     = registerNewUserViewModel.UserEmail;
            saveNewRegistrationDataToDB.UserPassword  = registerNewUserViewModel.UserPassword;
            saveNewRegistrationDataToDB.IsActive      = false;
            saveNewRegistrationDataToDB.LoginAttempts = 0;
            saveNewRegistrationDataToDB.IsLocked      = false;
            context.tbl_Login.Add(saveNewRegistrationDataToDB);
            context.SaveChanges();
        }
 public ActionResult getLogin(tbl_Login L)
 {
     if (ModelState.IsValid)
     {
         string uname = Request.Form["username"];
         string pasw  = Request.Form["password"];
         if (DBOperations.Check(uname, pasw))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.L = "Invalid details";
         }
     }
     return(View("Login"));
 }
예제 #9
0
        public async Task <ActionResult> Registeration([Bind(Include = "LoginUserName,LoginPassword,UserEmail,FirstName,LastName")] UserLogin clsuser)
        {
            if (ModelState.IsValid)
            {
                tbl_Login obj = new tbl_Login();
                obj.UserName     = clsuser.LoginUserName;
                obj.UserPassword = clsuser.LoginPassword;
                obj.UserEmail    = clsuser.UserEmail;
                obj.FirstName    = clsuser.FirstName;
                obj.LastName     = clsuser.LastName;

                dbobj.tbl_Login.Add(obj);
                await dbobj.SaveChangesAsync();

                return(RedirectToAction("Login"));
            }
            return(View());
        }
예제 #10
0
        public void CreateLogins()
        {
            /*
             * create test logins
             */

            foundLogin = _uow.Logins.Get(QueryExpressionFactory.GetQueryExpression <tbl_Login>()
                                         .Where(x => x.Name == TestDefaultConstants.LoginName).ToLambda())
                         .SingleOrDefault();

            if (foundLogin == null)
            {
                foundLogin = _uow.Logins.Create(
                    _map.Map <tbl_Login>(new LoginV1()
                {
                    Name        = TestDefaultConstants.LoginName,
                    LoginKey    = AlphaNumeric.CreateString(16),
                    IsDeletable = true,
                }));

                _uow.Commit();
            }
        }
예제 #11
0
        public void CreateLogins()
        {
            /*
             * create default logins
             */

            foundLogin = _uow.Logins.Get(QueryExpressionFactory.GetQueryExpression <tbl_Login>()
                                         .Where(x => x.Name == DefaultConstants.LoginName).ToLambda())
                         .SingleOrDefault();

            if (foundLogin == null)
            {
                foundLogin = _uow.Logins.Create(
                    _map.Map <tbl_Login>(new LoginV1()
                {
                    Name        = DefaultConstants.LoginName,
                    LoginKey    = DefaultConstants.LoginKey,
                    IsEnabled   = true,
                    IsDeletable = false,
                }));

                _uow.Commit();
            }
        }
예제 #12
0
 public static tbl_Login getUserLoginById(int id)
 {
     user = db.tbl_Login.First(p => p.id == id);
     return(user);
 }
예제 #13
0
 public ActionResult Register(tbl_Login model)
 {
     LogRepo.Register(model);
     return(RedirectToAction("Register", new { isreg = 1 }));
 }