Exemplo n.º 1
0
 public ResultHelper AddUserLogin(UserLoginDto userLoginDto)
 {
     try
     {
         if (IsThere(userLoginDto))
         {
             return(new ResultHelper(false, 0, ResultHelper.SuccessMessage));
         }
         userlogin item = new userlogin();
         item.UserLoginID = userLoginDto.UserLoginID;
         item.Password    = userLoginDto.Password;
         item.IpAdress    = userLoginDto.IpAdress;
         item.UserID      = userLoginDto.UserID;
         using (UnitOfWork unitOfWork = new UnitOfWork())
         {
             unitOfWork.GetRepository <userlogin>().Insert(item);
             unitOfWork.saveChanges();
             return(new ResultHelper(true, item.UserLoginID, ResultHelper.SuccessMessage));
         }
     }
     catch (Exception ex)
     {
         return(new ResultHelper(false, 0, ResultHelper.UnSuccessMessage));
     }
 }
Exemplo n.º 2
0
        public async Task <ActionResult> Index(userlogin u)
        {
            // EFConfiguration.SuspendExecutionStrategy = true;



            if (ModelState.IsValid)
            {
                userContext db = new userContext();

                var v = await db.USERS.Where(model => model.username.Equals(u.username) && model.password.Equals(u.password)).FirstOrDefaultAsync();

                if (v != null)
                {
                    if ("TEST" == u.username.ToString() && "TEST" == u.password.ToString())
                    {
                        return(RedirectToAction("site_data_test", "HistorySite"));
                    }
                }
            }

            // EFConfiguration.SuspendExecutionStrategy = false;

            return(View(u));
        }
Exemplo n.º 3
0
        public JsonResult UserLogin(String __RequestVerificationToken, String username, String userPass
                                    )
        {
            userLoging user_login = new userLoging();
            string     token      = __RequestVerificationToken;
            string     password   = Hash(userPass);
            string     msge;


            try
            {
                userlogin LoginUserx = db.userlogins.Where(a => a.username == username && a.password == password).FirstOrDefault();
                if (LoginUserx != null)
                {
                    user_login.msg     = "successful  login";
                    user_login.status  = true;
                    Session["user_ID"] = username;
                    return(Json(user_login));
                }
                else
                {
                    user_login.msg    = "invalid login username/password";
                    user_login.status = false;
                    return(Json(user_login));
                }
            }
            catch (Exception ex)
            {
                msge = ex.Message;
            }

            return(Json(user_login));
        }
Exemplo n.º 4
0
        public ActionResult Signup(loginfo l, roletable r, userlogin u)
        {
            if (ModelState.IsValid)
            {
                var username = db.loginfo.Where(a => a.username == l.username).FirstOrDefault();
                if (username == null)
                {
                    l.Balance = 0;
                    db.loginfo.Add(l);

                    db.SaveChanges();

                    ViewBag.balance   = l.Balance;
                    ViewBag.usercount = usercount += 1;
                    ViewBag.msg       = "USER REGISTERED SUCCESSFULLY";
                    ViewBag.mpin      = l.mpin;
                    ViewBag.user      = l.Account_No;
                    r.user_id         = l.Account_No;
                    r.Role            = "User";
                    db.roletable.Add(r);
                    db.SaveChanges();
                }
                else
                {
                    ViewBag.du = "This username is already exists";
                }
            }


            return(View());
        }
Exemplo n.º 5
0
        public ActionResult SignIn()
        {
            userlogin user = new userlogin();

            user = Checkcookie();


            return(View());
        }
Exemplo n.º 6
0
        //Task-1: User Login
        public int UserLogin(userlogin objuser)
        {
            userlogin objusercheck = objdb.userlogins.FirstOrDefault(u => u.username.Equals(objuser.username) && u.password.Equals(objuser.password));

            if (objusercheck != null)
            {
                return(objusercheck.loginid);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 7
0
        //Task-3: User Forgot Password
        public string GetPassword(userlogin objuser)
        {
            userlogin objusercheck = objdb.userlogins.FirstOrDefault(u => u.username.Equals(objuser.username) && u.secquestion.Equals(objuser.secquestion) && u.answer.Equals(objuser.answer));

            if (objusercheck != null)
            {
                return(objusercheck.password);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
 //Task-2: User Registration
 public int UserRegistration(userlogin objuser)
 {
     try
     {
         objdb.userlogins.Add(objuser);
         objdb.SaveChanges();
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Exemplo n.º 9
0
 //Task-4: User Change Password
 public int UserChangePassword(userlogin objuser, string newpassword)
 {
     objuser          = objdb.userlogins.Find(objuser.loginid);
     objuser.password = newpassword;
     try
     {
         objdb.SaveChanges();
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Exemplo n.º 10
0
        public ActionResult UserLogin(FormCollection coll)
        {
            userlogin objuser = new userlogin();

            objuser.username   = Request["txtUName"];
            objuser.password   = Request["txtUPwd"];
            Session["loginid"] = objusermodel.UserLogin(objuser);
            if ((int)Session["loginid"] != 0)
            {
                Session["name"] = objusermodel.CurrentUserName((int)Session["loginid"]);
                return(View("~/Views/User/UserHome.cshtml"));
            }
            else
            {
                ViewData["lblUloginMsg"] = "invalid username/password";
                return(View("~/Views/Home/UserLogin.cshtml"));
            }
        }
Exemplo n.º 11
0
        public ActionResult login(userlogin uvm)
        {
            user_register s = db.user_register.Where(x => x.user_cnic == uvm.user_cnic && x.user_email == uvm.user_email)
                              .SingleOrDefault();

            if (s != null)
            {
                Session["id"] = s.reg_id;
                return(RedirectToAction("prophile"));
            }
            else
            {
                ViewBag.msg = "No Record Found";
            }


            return(View());
        }
Exemplo n.º 12
0
        public ActionResult UserRegistration(userlogin objuserreg)
        {
            objuserreg.loginid = int.Parse(Request["txtLoginId"]);
            objuserreg.status  = "not active";
            int i = objusermodel.UserRegistration(objuserreg);

            if (i == 1)
            {
                ViewData["regmsg"]      = "Registration Successfull";
                ViewData["regmsgstyle"] = "position:relative;left:110px;color:green";
                ModelState.Clear();
            }
            else
            {
                ViewData["regmsg"]      = "Username already used";
                ViewData["regmsgstyle"] = "position:relative;left:110px;color:red";
            }
            ViewData["txtLoginId"] = objdb.userlogins.Select(u => u.loginid).DefaultIfEmpty(0).Max() + 1;
            return(View());
        }
Exemplo n.º 13
0
        public ActionResult Singin(String login, String password, String remember)
        {
            bool remem = remember != null;

            if (new ToDoMemberShipProvider().ValidateUser(login, EncryptHelper.encryptPassword(password)))
            {
                using (var dc = new todo_listEntities())
                {
                    userlogin user     = dc.userlogins.FirstOrDefault(u => u.login.Equals(login));
                    var       myCookie = new HttpCookie("myCookie");
                    myCookie.Values.Add("id", user.iduser.ToString());
                    Response.Cookies.Add(myCookie);
                    FormsAuthentication.SetAuthCookie(login, remem);
                }
                return(RedirectToAction("Index", "Home"));
            }

            TempData["error"] = "Login or password is invalid";
            return(RedirectToAction("Index", "Login"));
        }
Exemplo n.º 14
0
        public ActionResult UserForgotPassword(FormCollection UFPwdCollection)
        {
            userlogin objuser = new userlogin();

            objuser.username    = UFPwdCollection["txtUName"].ToString();
            objuser.secquestion = UFPwdCollection["DropSecQueList"].ToString();
            objuser.answer      = UFPwdCollection["txtUAnswer"].ToString();
            string upwd = objusermodel.GetPassword(objuser);

            if (upwd != null)
            {
                ViewData["UPwdMsg"]      = upwd;
                ViewData["uflabelstyle"] = "color:green;position:relative;left:120px";
            }
            else
            {
                ViewData["UPwdMsg"]      = "Wrong Details Entered";
                ViewData["uflabelstyle"] = "color:red;position:relative;left:120px";
            }
            return(View());
        }
Exemplo n.º 15
0
        public ActionResult UserStatusChange()
        {
            userlogin objuserlogin = new userlogin();

            if (Request.QueryString["status"] == "not active")
            {
                objuserlogin.loginid = int.Parse(Request.QueryString["lid"]);
                objadminmodel.ChangeUserStatus(objuserlogin, "active");
            }
            if (Request.QueryString["status"] == "active")
            {
                objuserlogin.loginid = int.Parse(Request.QueryString["lid"]);
                objadminmodel.ChangeUserStatus(objuserlogin, "blocked");
            }
            if (Request.QueryString["status"] == "blocked")
            {
                objuserlogin.loginid = int.Parse(Request.QueryString["lid"]);
                objadminmodel.ChangeUserStatus(objuserlogin, "active");
            }
            ViewBag.users = objadminmodel.GetUserList();
            return(View("~/Views/Admin/UsersList.cshtml"));
        }
Exemplo n.º 16
0
        public userlogin Checkcookie()
        {
            userlogin usrl = null;
            string    username = string.Empty, password = string.Empty;

            if (Request.Cookies["Username"] != null)
            {
                username = Request.Cookies["Username"].Value;
            }
            if (Request.Cookies["Password"] != null)
            {
                password = Request.Cookies["Password"].Value;
            }
            if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password))
            {
                usrl = new userlogin {
                    Username = username, Password = password
                }
            }
            ;
            return(usrl);
        }
Exemplo n.º 17
0
        public UserLoginDto GetUserLogin(int userLoginID)
        {
            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    userlogin item = new userlogin();
                    item = unitOfWork.GetRepository <userlogin>().GetById(x => x.UserLoginID == userLoginID);
                    UserLoginDto userLoginDto = new UserLoginDto();
                    userLoginDto.Password     = item.Password;
                    userLoginDto.CreationDate = Convert.ToDateTime(item.CreationDate); //TODO: tarih parse işlemi gerekiyor mu?
                    userLoginDto.IpAdress     = item.IpAdress;
                    userLoginDto.UserID       = Convert.ToInt32(item.UserID);

                    return(userLoginDto);
                }
            }
            catch (Exception)
            {
                return(new UserLoginDto());
            }
        }
Exemplo n.º 18
0
        public ActionResult Loginpage(userlogin u, string ReturnUrl)
        {
            if (u.username == "Admin" && u.password == "Admin")
            {
                return(RedirectToAction("Index", "Admin"));
            }
            if (ModelState.IsValid)
            {
                var user = db.loginfo.Where(x => x.username == u.username && x.password == u.password).FirstOrDefault();

                if (user != null)
                {
                    FormsAuthentication.SetAuthCookie(u.username, false);
                    Session["uname"]   = u.username.ToString();
                    Session["ID"]      = user.Account_No;
                    Session["balance"] = user.Balance;
                    Session["pass"]    = user.password;
                    Session["mpin"]    = user.mpin;
                    if (ReturnUrl != null)
                    {
                        return(Redirect(ReturnUrl));
                    }
                    else
                    {
                        return(Redirect("/Home/Index"));
                    }
                }
                else
                {
                    ViewBag.ERROR = "USERNAME AND PASSWORD INVALID ";
                }
            }
            else
            {
                ViewBag.empty = "All Fields Required";
            }
            return(View());
        }
Exemplo n.º 19
0
        public ActionResult user_login(userlogin obj, string clentcapt)
        {
            string servercaptcha = null;
            string clientcaptcha = null;

            if (Session["CAPTCHA"] == null)
            {
                Session["CAPTCHA"] = objcommon.getrandomtext();
            }
            else
            {
                servercaptcha = Session["CAPTCHA"].ToString();
                clientcaptcha = clentcapt;
                if (servercaptcha == clentcapt)
                {
                    Boolean result = objcommon.checkuser(obj.user_name1, obj.user_password);
                    if (result == true)
                    {
                        Session["user_active"] = obj.user_name1;
                        return(RedirectToAction("Dash", "Dashboard"));
                    }
                    else
                    {
                        ViewBag.errormessage = "wrong credentials!!!!!1";
                        Session["CAPTCHA"]   = objcommon.getrandomtext();
                        return(View());
                    }
                }
                else
                {
                    ViewBag.errormessage = "Invalid CAptCha!!!!!!";
                    Session["CAPTCHA"]   = objcommon.getrandomtext();
                    return(View());
                }
            }

            return(View());
        }
Exemplo n.º 20
0
        //[ValidateAntiForgeryToken]
        public JsonResult UserRegistration(//String __RequestVerificationToken,
            String firstname, String lastname, String email, String userPass
            )
        {
            newUser user_reg = new newUser();

            user_reg.msg    = "test";
            user_reg.status = true;

            try
            {
                userlogin new_user2 = new userlogin();

                new_user2.username    = firstname + "." + lastname;
                new_user2.password    = Hash(userPass);
                new_user2.email       = email;
                new_user2.roleID      = 1;
                new_user2.datecreated = DateTime.Now;



                db.userlogins.Add(new_user2);
                db.SaveChanges();


                user_reg.msg    = "User created succesfully!!";
                user_reg.status = true;
                return(Json(user_reg));
            }
            catch (Exception ex)
            {
                user_reg.msg    = "Error in user creation -- " + ex.Message;
                user_reg.status = false;
                return(Json(user_reg));
            }
        }
 public userlogin AddNewUser(userlogin newUser)
 {
     return(DAL.NewLogin(newUser));
 }
Exemplo n.º 22
0
        public ActionResult SignIn(userlogin user)
        {
            if (user.IsValid(user.Username, user.Password))
            {
                Session["UserId"]   = user.UserId.ToString();
                Session["Username"] = user.Username.ToString();

                if (user.Rememberme)
                {
                    HttpCookie cookieusername = new HttpCookie("Username");
                    cookieusername.Expires = DateTime.Now.AddSeconds(3600);
                    cookieusername.Value   = user.Username;
                    Response.Cookies.Add(cookieusername);
                    HttpCookie cookiepassword = new HttpCookie("Password");
                    cookiepassword.Expires = DateTime.Now.AddSeconds(3600);
                    cookiepassword.Value   = user.Password;
                    Response.Cookies.Add(cookiepassword);
                }


                if (user.Username == "admin" || user.Username == "ADMIN")
                {
                    return(RedirectToAction("AdminIndex", "Admin"));
                }


                UserLayer ulayer = new UserLayer();
                ulayer.saveLoginhistory(user);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewData["Name"] = "Credentials does not match our records";
                return(View());
            }



            /*
             * if (user.IsValid(user.Username, user.Password))
             * {
             *  //  FormsAuthentication.SetAuthCookie(user.Email, model.RememberMe);
             * // ViewData["IDV"] = user.UserId;
             *
             *
             *  Session["UserId"] = user.UserId.ToString();
             *  Session["Username"] = user.Username.ToString();
             *
             *  return RedirectToAction("Index", "Home");
             *
             * }
             * else
             * {
             *  ModelState.AddModelError("", "The user name or password provided is incorrect.");
             *
             * }
             *
             * ViewData["Name"] = "Credentials does not match our records";
             *
             * return View();
             */
        }
Exemplo n.º 23
0
        //Getting current User Name
        public string CurrentUserName(int loginid)
        {
            userlogin objusercheck = objdb.userlogins.Find(loginid);

            return(objusercheck.name);
        }
Exemplo n.º 24
0
        public userlogin NewLogin(userlogin newUser)
        {
            long id = conn.Insert <userlogin>(newUser);

            return(conn.Get <userlogin>(id));
        }
Exemplo n.º 25
0
 //Task-5: Change User Tasks (Approve/Block/UnBlock)
 public void ChangeUserStatus(userlogin objuser, string status)
 {
     objuser        = objdb.userlogins.Find(objuser.loginid);
     objuser.status = status;
     objdb.SaveChanges();
 }