Beispiel #1
0
        public ActionResult Sign(string account, string password, string rUrl, string remember)
        {
            string  res      = (new SystemAccountManager()).Login(account, password);
            MsgInfo loginMsg = JsonConvert.DeserializeObject <MsgInfo>(res);

            if (!loginMsg.IsError)
            {
                LoginUsers loginUser   = JsonConvert.DeserializeObject <LoginUsers>(loginMsg.Msg);
                string     strUserData = JsonConvert.SerializeObject(loginUser);
                //保存身份信息
                FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, account, DateTime.Now, DateTime.Now.AddHours(12), false, strUserData);
                CookieHelper.Add(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(Ticket), RootDomain);//加密身份信息,保存至Cookie

                loginMsg.Msg = rUrl;
                if (remember == "true")
                {
                    CookieHelper.Add("remember", loginUser.Account + "$" + Security.DESEncrypt(password), RootDomain);
                }
                else
                {
                    CookieHelper.Add("remember", "", RootDomain);
                }
            }
            return(Json(loginMsg));
        }
 public IActionResult LoginApp(LoginUsers objUser)
 {
     try {
         if (objUser.UserName != null && objUser.Password != null)
         {
             var getUser = dbContext.LoginUsers.Where(u => u.UserName == objUser.UserName && u.Password == objUser.Password).FirstOrDefault();
             if (getUser != null)
             {
                 HttpContext.Session.SetString("UserName", getUser.UserName);
                 HttpContext.Session.SetString("FullName", getUser.FullName);
                 HttpContext.Session.SetString("UserId", Convert.ToString(getUser.UserId));
                 return(Json(new { status = true, message = "Login Successfully" }));
             }
             else
             {
                 return(Json(new { status = false, message = "Invalid Username or Password" }));
             }
         }
         else
         {
             return(Json(new { status = false, message = "Please enter proper value" }));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #3
0
        public async Task <IActionResult> PutLoginUsers(int id, LoginUsers loginUsers)
        {
            if (id != loginUsers.UserID)
            {
                return(BadRequest());
            }

            _context.Entry(loginUsers).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoginUsersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult Validar(LoginUsers credentials)
        {
            var sendServicioResponse = SendtoOtherApi("http://localhost:5050/Home/GetUsuario?usua.Usua=" + credentials.Usua + "&usua.Pass="******"");

            if (sendServicioResponse.StatusDescription.ToUpper() == "OK" && sendServicioResponse.StatusCode == HttpStatusCode.OK)
            {
                ViewBag.message = "";

                userResult validar;
                var        json = sendServicioResponse.Content;
                validar = JsonConvert.DeserializeObject <userResult>(json);
                List <productos> lst = new List <productos>();
                if (validar.Success == true)
                {
                    var sendServicioResponse1 = SendtoOtherApi("http://localhost:5050/Home/GetListProductos");

                    if (sendServicioResponse1.StatusDescription.ToUpper() == "OK" && sendServicioResponse1.StatusCode == HttpStatusCode.OK)
                    {
                        productosGet products;
                        var          json1 = sendServicioResponse1.Content;
                        products = JsonConvert.DeserializeObject <productosGet>(json1);
                        lst      = products.Data;
                    }
                    return(View("Index", lst));
                }
                else
                {
                    ViewBag.message = "Las credenciales son incorrectas";
                    return(View("Login"));
                }
            }
            return(View());
        }
        public ActionResult UserList()
        {
            DBContext  db       = new DBContext();
            LoginUsers UserData = LI.GetLoginUserInfo("");

            SqlConnection conn    = new SqlConnection();
            string        sqlConn = WebConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;

            conn.ConnectionString = sqlConn;

            string     sqlQuery = "SELECT * FROM [AspNetUsers]  WHERE CompanyName = '" + UserData.CompanyName + "'";
            SqlCommand cmd      = new SqlCommand(sqlQuery, conn);

            conn.Open();
            SqlDataReader          dr   = cmd.ExecuteReader();
            List <UserListDetails> list = new List <UserListDetails>();

            while (dr.Read())
            {
                list.Add(new UserListDetails()
                {
                    UserName    = dr["UserName"].ToString(),
                    CompanyName = dr["CompanyName"].ToString(),
                    Id          = dr["Id"].ToString()
                });
            }
            dr.Close();
            conn.Close();

            return(PartialView("UserListPartial", list));
        }
Beispiel #6
0
        public async Task <IActionResult> PostLogin(LoginUsers _userData)
        {
            if (_userData != null && _userData.Email != null && _userData.Password != null)
            {
                var user = await GetUsers(_userData.Email, _userData.Password);

                if (user != null)
                {
                    //create claims details based on the user information
                    var claims = new[] {
                        new Claim(JwtRegisteredClaimNames.Sub, _configuration["Jwt:Subject"]),
                        new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
                        new Claim(JwtRegisteredClaimNames.Iat, DateTime.UtcNow.ToString()),
                        new Claim("Id", user.UserID.ToString()),
                        new Claim("Email", user.Email)
                    };

                    var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["Jwt:Key"]));

                    var signIn = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);

                    var token = new JwtSecurityToken(_configuration["Jwt:Issuer"], _configuration["Jwt:Audience"], claims, expires: DateTime.UtcNow.AddDays(1), signingCredentials: signIn);

                    return(Ok(new JwtSecurityTokenHandler().WriteToken(token)));
                }
                else
                {
                    return(BadRequest("Invalid credentials"));
                }
            }
            else
            {
                return(BadRequest());
            }
        }
Beispiel #7
0
        public void OffLine()
        {
            Console.WriteLine("{0} is offline!", uName);

            var uu = LoginUsers.Find(a => a.UserName == uName);

            if (uu != null)
            {
                LoginUsers.Remove(uu);
            }

            if (DicUserSockets.ContainsKey(uName))
            {
                DicUserSockets.Remove(uName);
            }

            var userService = new UserService(uName);
            var theFriends  = userService.GetFriends();

            foreach (var f in theFriends)
            {
                if (DicUserSockets.ContainsKey(f.UserName))
                {
                    LogoutMsg logout = new LogoutMsg(uName);
                    var       sock   = DicUserSockets[f.UserName];
                    logout.Send(sock);
                }
            }
        }
        public IActionResult Login(LoginUsers userSubmission)
        {
            if (ModelState.IsValid)
            {
                // If inital ModelState is valid, query for a user with provided email
                var userInDb = dbContext.Users.FirstOrDefault(u => u.Email == userSubmission.Email);
                // If no user exists with provided email
                if (userInDb == null)
                {
                    // Add an error to ModelState and return to View!
                    ModelState.AddModelError("Email", "Invalid Email");
                    return(View("Index"));
                }

                // Initialize hasher object
                var hasher = new PasswordHasher <LoginUsers>();

                // varify provided password against hash stored in db
                var result = hasher.VerifyHashedPassword(userSubmission, userInDb.Password, userSubmission.Password);

                // result can be compared to 0 for failure
                if (result == 0)
                {
                    // handle failure (this should be similar to how "existing email" is handled)
                    ModelState.AddModelError("Password", "Wrong Password");
                    return(View("Index"));
                }


                HttpContext.Session.SetInt32("id", userInDb.UserId);
                Console.WriteLine(HttpContext.Session.GetInt32("id"));
                return(RedirectToAction("Success"));
            }
            return(View("Index"));
        }
Beispiel #9
0
        public ActionResult Delete()
        {
            // Create New Objects.
            DBStuff    dal    = new DBStuff();
            Login      myUser = new Login();
            LoginUsers logU   = new LoginUsers();

            // The list of Orders from Db.
            List <Login> objCars = dal.CustomersLog.ToList <Login>();

            // Id Customer to delete the order.
            myUser.ID = Request.Form["GetIDtext2"].ToString();

            // find the product we are looking for by ProductId.
            foreach (Login ob in objCars)
            {
                if (myUser.ID == ob.ID)
                {
                    // remove the product we want form the list.
                    dal.CustomersLog.Remove(ob);
                    dal.SaveChanges();
                }
            }
            return(View("DeleteOrder"));
        }
Beispiel #10
0
        // GET: Login
        public ActionResult Connecter()
        {
            try
            {
                string      identifiant = Request.Form["identifiant"];
                string      mdp         = Request.Form["mdp"];
                LoginUsers  loginUsers  = new LoginUsers(identifiant, mdp);
                Utilisateur utilisateur = Utilisateur.Connecter(loginUsers);
                HttpContext.Session["utilisateur"] = utilisateur;
                Utilisateur userSession = HttpContext.Session["utilisateur"] as Utilisateur;
                string      idposte     = userSession.Poste.IdPoste;
                Commande    commande    = new Commande();
                switch (idposte)
                {
                case "1":
                    AccesSageDAO    accesSageDAO         = new AccesSageDAO();
                    Comptoir        comptoir             = accesSageDAO.GetComptoirByNomCaisse(utilisateur.Identifiants);
                    List <Commande> listeCommandeEnCours = commande.GetListeCommandeEnCours(comptoir);
                    ViewData["listeCommandeEnCours"] = listeCommandeEnCours;
                    ViewBag.date        = DateTime.Now.ToString("yyyy-MM-dd");
                    ViewBag.titre       = "Commande";
                    ViewBag.espaceVente = "ok";
                    ViewBag.userName    = utilisateur.Prenoms;
                    return(View("Accueil_vente"));

                case "2":
                    ViewBag.date = DateTime.Now.ToString("yyyy-MM-dd");
                    List <Commande> commandeEncours = commande.GetListeToutCommandeEnCours();
                    string          titre           = "";
                    if (commandeEncours.Count == 0)
                    {
                        titre = "Attente commande";
                    }
                    else
                    {
                        titre = "Commande en cours";
                    }
                    ViewBag.titre = titre;
                    ViewData["commandeEnCours"] = commandeEncours;
                    ViewBag.espaceStock         = "ok";
                    ViewBag.userName            = utilisateur.Prenoms;
                    return(View("Accueil_stock"));

                case "4":
                    ViewData["utilisateursValide"]    = utilisateur.GetUtilisateurValidation("1");
                    ViewData["utilisateursNonValide"] = utilisateur.GetUtilisateurValidation("0");
                    ViewBag.titre    = "Gestion des utilisateurs";
                    ViewBag.userName = utilisateur.Prenoms;
                    return(View("Admin"));

                default:
                    return(View("login"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.erreur = ex.Message;
                return(View("Login"));
            }
        }
Beispiel #11
0
 public IActionResult Login(LoginUsers userSubmission)
 {
     if (ModelState.IsValid)
     {
         var userInDb = dbContext.Users
                        .FirstOrDefault(u => u.Email == userSubmission.LogEmail);
         if (userInDb is null)
         {
             ModelState.AddModelError("Email", "Invalid Email");
             return(View("LoginAndReg"));
         }
         var hasher = new PasswordHasher <LoginUsers>();
         var result = hasher.VerifyHashedPassword(
             userSubmission,
             userInDb.Password,
             userSubmission.LogPassword)
         ;
         var one = hasher;
         if (result == 0)
         {
             ModelState.AddModelError("LogPassword", "Wrong Password");
             return(View("LoginAndReg"));
         }
         HttpContext.Session.SetInt32("id", userInDb.userId);
         return(RedirectToAction("Success", "Message"));
     }
     return(View("LoginAndReg"));
 }
Beispiel #12
0
        public async Task <bool> LoginUser(LoginUsers loginUsers)
        {
            var usercount = await _context.RegisterUser.Where(user => user.Username == loginUsers.Username &&
                                                              user.Password == PasswordEncryption.HashPassword(loginUsers.Password) &&
                                                              user.ApiKey == loginUsers.ApiKey)
                            .CountAsync();

            if (usercount > 0)
            {
                var loginUser = new LoginUsers
                {
                    Username  = loginUsers.Username,
                    Password  = PasswordEncryption.HashPassword(loginUsers.Password),
                    ApiKey    = loginUsers.ApiKey,
                    LoginDate = DateTime.Now
                };

                await _context.LoginUser.AddAsync(loginUser);

                await _context.SaveChangesAsync();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #13
0
        public JsonResult ResetPassword(string oldPassword, string newPassword, string confirmPassword)
        {
            bool result   = false;
            var  _objUser = this._UserBAL.LoginUserBAL(CurrentUser.Email);

            if (_objUser != null)//check if the email is found
            {
                if (Crypto.VerifyPassword(oldPassword, _objUser.Password))
                {
                    result = true;
                }
                if (newPassword.Equals(confirmPassword))
                {
                    result = true;
                }
            }
            if (result)
            {
                LoginUsers _objUsers = new LoginUsers
                {
                    Password    = Crypto.CreatePasswordHash(newPassword),
                    UserID      = Convert.ToInt64(Session["UserId"]),
                    UpdatedBy   = Convert.ToInt64(Session["UserId"]),
                    UpdatedDate = DateTime.UtcNow
                };
                var res = this._UserBAL.LoginUsers_UpdatePasswordBAL(_objUsers);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
 public IActionResult loginSubmit(LoginUsers userSubmission)
 {
     if (ModelState.IsValid)
     {
         //if null, there is no user with that email, they need to register
         RegisterUsers userInDB = dbContext.Users.FirstOrDefault(a => a.Email == userSubmission.Email);
         if (userInDB == null)
         {
             ModelState.AddModelError("Email", "Invalid Email/Password combination.");
             return(View("Login"));
         }
         else
         {
             var hasher = new PasswordHasher <LoginUsers>();
             var result = hasher.VerifyHashedPassword(userSubmission, userInDB.Password, userSubmission.Password);
             if (result == 0)
             {
                 ModelState.AddModelError("Email", "Invalid Email/Password combination!");
                 return(View("Login"));
             }
         }
         //put the user into session
         HttpContext.Session.SetInt32("id", userInDB.UsersId);
         return(RedirectToAction("Success"));
     }
     else
     {
         return(View("Login"));
     }
 }
Beispiel #15
0
        public Utilisateur GetUtilisateurByLogin(LoginUsers loginUsers)
        {
            Utilisateur     reponse   = new Utilisateur();
            Connexion       connexion = new Connexion();
            string          sql       = "select * from utilisateur where IDENTIFIANTS='" + loginUsers.Identifiant + "' and MDP = '" + loginUsers.Mdp + "' and ETAT='1'";
            MySqlCommand    command   = new MySqlCommand(sql, connexion.GetConnection());
            MySqlDataReader dataReader;

            connexion.GetConnection().Open();
            dataReader = command.ExecuteReader();
            PosteDAO posteDAO = new PosteDAO();

            try
            {
                if (dataReader.Read().ToString() == "True")
                {
                    Poste poste = posteDAO.GetPosteById(dataReader["ID_POSTE"].ToString());
                    reponse         = new Utilisateur(dataReader["ID_UTILISATEUR"].ToString(), poste, dataReader["NOM_UTILISATEUR"].ToString(), dataReader["PRENOMS"].ToString(), dataReader["IDENTIFIANTS"].ToString(), dataReader["MDP"].ToString());
                    reponse.EtatMdp = dataReader["etatmdp"].ToString();
                }
                else
                {
                    throw new Exception("Identifiants / mot de passe invalide");
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
Beispiel #16
0
        public ActionResult UpdateOrder()
        {
            LoginUsers log      = new LoginUsers();
            Login      ObjOrder = new Login();
            DBStuff    dal      = new DBStuff();

            ObjOrder.ID        = Request.Form["GetIDtext"].ToString();
            ObjOrder.StartDate = Request.Form["startDate1"].ToString();
            ObjOrder.EndDate   = Request.Form["endDate1"].ToString();
            ObjOrder.CarSelect = "none";

            Login np1 =
                (from x in dal.CustomersLog
                 where x.ID == ObjOrder.ID
                 select x).ToList <Login>()[0];

            if (ModelState.IsValid)
            {
                np1.StartDate = ObjOrder.StartDate;
                np1.EndDate   = ObjOrder.EndDate;
                dal.SaveChanges();
            }
            ObjOrder = np1;
            return(RedirectToAction("SelectVehicle", ObjOrder));
        }
Beispiel #17
0
        public ActionResult Sign(LoginParameter loginPara)
        {
            string  res      = mUserMgr.Login(loginPara.MobileOrEmail, loginPara.Password);
            MsgInfo loginMsg = JsonConvert.DeserializeObject <MsgInfo>(res);

            if (!loginMsg.IsError)
            {
                LoginUsers loginUser   = JsonConvert.DeserializeObject <LoginUsers>(loginMsg.Msg);
                string     strUserData = JsonConvert.SerializeObject(loginUser);

                //保存身份信息
                FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, loginUser.Mobile, DateTime.Now, DateTime.Now.AddHours(12), false, strUserData);
                CookieHelper.Add(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(Ticket), RootDomain);//加密身份信息,保存至Cookie
                loginMsg.Msg = loginPara.ReturnUrl;
                if (loginPara.IsRemember)
                {
                    CookieHelper.Add("remember", loginUser.Mobile + "$" + Security.DESEncrypt(loginPara.Password), RootDomain);
                }
                else
                {
                    CookieHelper.Remove("remember");
                }
            }
            return(Json(loginMsg));
        }
Beispiel #18
0
        public async Task <ActionResult <LoginUsers> > PostLoginUsers(LoginUsers loginUsers)
        {
            _context.LoginUsers.Add(loginUsers);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLoginUsers", new { id = loginUsers.UserID }, loginUsers));
        }
        public ActionResult ShowSearchMenu()
        {
            LoginUsers   UserData = LI.GetLoginUserInfo("");
            MyLastAction myla     = LI.GetUserCurrentAction("");

            string sTableName = UserData.CompanyName.ToString().Trim().ToUpper().Replace(" ", "_") + "_LevelInfos";

            if (myla.Oper == "LV")
            {
                sTableName = UserData.CompanyName.ToString().Trim().ToUpper().Replace(" ", "_") + "_LegalInfos";
            }

            int Version = Convert.ToInt32(myla.Version);
            var UFH     = (from ufh in db.UploadFilesHeaders where ufh.VersionNo == Version select ufh).FirstOrDefault();

            DataTable ShowTable = null;

            if (UFH != null)
            {
                Common ComClass = new Common();
                ShowTable = ComClass.SQLReturnDataTable("SELECT LEVEL_ID," + UFH.ExcelDownLoadFields + " FROM " + "[" + sTableName + "]");
            }
            if (ShowTable == null)
            {
                ShowTable = new DataTable();
                ShowTable.Columns.Add("Dummy", typeof(string));
                DataRow dr = ShowTable.NewRow();
                dr["Dummy"] = "None";
                ShowTable.Rows.Add(dr);
            }

            return(PartialView("ShowSearchMenu", ShowTable));;
        }
        public async Task <dynamic> ChangePassword([FromBody] ValidateLoginUsersAddRequest validateloginuser)
        {
            UpdateLoginUsersResponse registrationResponse = new UpdateLoginUsersResponse();
            var response = await _cloudantService.GetAllAsync(DBNames.loginusers.ToString());

            BulkData loginusers          = JsonConvert.DeserializeObject <BulkData>(response);
            var      UpdatedLoginDetails = loginusers.rows.FirstOrDefault(a => a.doc.Username == validateloginuser.Username);

            HashSalt hashSalt = Helper.GenerateSaltedHash(64, validateloginuser.Password);

            LoginUsers loginuser = new LoginUsers();

            loginuser.Username     = UpdatedLoginDetails.doc.Username;
            loginuser.Password     = hashSalt.Hash;
            loginuser.Passwordsalt = hashSalt.Salt;
            loginuser._id          = UpdatedLoginDetails.doc._id;
            loginuser.Id           = UpdatedLoginDetails.doc.Id;
            loginuser.EmailID      = UpdatedLoginDetails.doc.EmailID;
            loginuser.Type         = UpdatedLoginDetails.doc.Type;
            loginuser._rev         = UpdatedLoginDetails.doc._rev;

            if (_postUserLoginProcessor != null)
            {
                return(await _putUserLoginProcessor.PutExistingUserRecord(loginuser, _cloudantService));
            }
            else
            {
                return(new string[] { "No database connection" });
            }
        }
Beispiel #21
0
 /// <summary>
 /// Logins the users duplication check dal.
 /// </summary>
 /// <param name="_objUsers">The object users.</param>
 /// <returns>System.Int32.</returns>
 public int LoginUsersAsTrainer_DuplicationCheckDAL(LoginUsers _objUsers)
 {
     return(ExecuteScalarSPInt32("TMS_UsersAsTrainer_DuplicationCheckForOrganization",
                                 ParamBuilder.Par("Email", _objUsers.Email),
                                 ParamBuilder.Par("organizationId", _objUsers.CompanyID)
                                 ));
 }
Beispiel #22
0
 /// <summary>
 /// Logins the users delete dal.
 /// </summary>
 /// <param name="_objUsers">The object users.</param>
 /// <returns>System.Int32.</returns>
 public int LoginUsers_UnlockDAL(LoginUsers _objUsers)
 {
     return(ExecuteScalarInt32Sp("TMS_Users_Unlock",
                                 ParamBuilder.Par("UserID", _objUsers.UserID),
                                 ParamBuilder.Par("UpdatedBy", _objUsers.UpdatedBy),
                                 ParamBuilder.Par("UpdatedDate", _objUsers.UpdatedDate)));
 }
Beispiel #23
0
        /// <summary>
        /// Logins the users duplication check dal.
        /// </summary>
        /// <param name="_objUsers">The object users.</param>
        /// <returns>System.Int32.</returns>
        public int LoginUsers_DuplicationCheckUpdateDAL(LoginUsers _objUsers)
        {
            return(ExecuteScalarSPInt32("TMS_Users_DuplicationCheckUpdate",
                                        ParamBuilder.Par("Email", _objUsers.Email),
                                        ParamBuilder.Par("UserID ", _objUsers.UserID)

                                        ));
        }
Beispiel #24
0
 /// <summary>
 /// Logins the users update profile image dal.
 /// </summary>
 /// <param name="_objUsers">The object users.</param>
 /// <returns>System.Int32.</returns>
 public int LoginUsers_UpdateProfileImageDAL(LoginUsers _objUsers)
 {
     return(ExecuteScalarInt32Sp("TMS_Users_UpdateProfileImage",
                                 ParamBuilder.Par("UserID", _objUsers.UserID),
                                 ParamBuilder.Par("UpdatedBy", _objUsers.UpdatedBy),
                                 ParamBuilder.Par("UpdatedDate", _objUsers.UpdatedDate),
                                 ParamBuilder.Par("ProfileImage", _objUsers.ProfileImage)
                                 ));
 }
Beispiel #25
0
        public string GetToken(LoginUsers loginUsers)
        {
            SecurityTokenDescriptor tokenDescriptor = GetTokenDescriptor(loginUsers);
            var           tokenHandler  = new JwtSecurityTokenHandler();
            SecurityToken securityToken = tokenHandler.CreateToken(tokenDescriptor);
            string        token         = tokenHandler.WriteToken(securityToken);

            return(token);
        }
Beispiel #26
0
        public ActionResult Index(Register value)
        {
            MsgInfo returnMsg = new MsgInfo
            {
                IsError = false,
                Msg     = "",
                MsgNo   = (int)ErrorEnum.成功
            };

            string code = Convert.ToString(CacheHelper.GetCache("code_" + Session.SessionID));

            if (code != value.MobileYzm)
            {
                returnMsg.IsError = true;
                returnMsg.Msg     = "手机验证码错误";
                returnMsg.MsgNo   = (int)ErrorEnum.失败;
                return(Json(returnMsg));
            }


            UserInfo user = new UserInfo
            {
                CreateDate = DateTime.Now,
                CreateIP   = this.GetIP,
                Mobile     = value.Mobile,
                Email      = Guid.NewGuid().ToString(),
                Status     = (int)UserStatusEnum.正常,
                UserType   = value.UserType,
                Password   = Security.DESEncrypt(value.Password)
            };

            UserManager userMgr = new UserManager();
            int         id      = userMgr.Create(user);

            if (id > 0)
            {
                LoginUsers loginUser = new LoginUsers
                {
                    Avatar = string.Empty,
                    Email  = string.Empty,
                    Id     = id,
                    IsVIP  = false,
                    Mobile = value.Mobile
                };
                string strUserData = JsonConvert.SerializeObject(loginUser);
                //保存身份信息
                FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, loginUser.Mobile, DateTime.Now, DateTime.Now.AddHours(12), false, strUserData);
                CookieHelper.Add(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(Ticket), RootDomain);//加密身份信息,保存至Cookie
                returnMsg.Msg = "成功";
            }
            else
            {
                returnMsg.Msg = "失败";
            }
            return(Json(returnMsg));
        }
Beispiel #27
0
        public ActionResult CustomerOrder()
        {
            DBStuff      dal     = new DBStuff();
            List <Login> objCars = dal.CustomersLog.ToList <Login>();
            LoginUsers   logu    = new LoginUsers();

            logu.user  = new Login();
            logu.users = objCars;
            return(View(logu));
        }
 public async Task <dynamic> Update([FromBody] LoginUsers loginuser)
 {
     if (_postUserLoginProcessor != null)
     {
         return(await _putUserLoginProcessor.PutExistingUserRecord(loginuser, _cloudantService));
     }
     else
     {
         return(new string[] { "No database connection" });
     }
 }
Beispiel #29
0
 public async Task <string> Authenticate(LoginUsers loginUsers)
 {
     if (await _repositoryLogin.LoginUser(loginUsers) == true)
     {
         string securityToken = _repositoryTokenService.GetToken(loginUsers);
         return(securityToken);
     }
     else
     {
         return("There's no such user...");
     }
 }
        public async Task <dynamic> EditDetails([FromBody] EditDetails editDetails)
        {
            var response = await _cloudantService.GetAllAsync(DBNames.loginusers.ToString());

            BulkData   loginusers          = JsonConvert.DeserializeObject <BulkData>(response);
            var        UpdatedLoginDetails = loginusers.rows.FirstOrDefault(a => a.doc.Username == editDetails.Username);
            LoginUsers loginuser           = new LoginUsers();

            if (editDetails.Password != "")
            {
                HashSalt hashSalt = Helper.GenerateSaltedHash(64, editDetails.Password);
                loginuser.Password     = hashSalt.Hash;
                loginuser.Passwordsalt = hashSalt.Salt;
            }
            else
            {
                loginuser.Password     = UpdatedLoginDetails.doc.Password;
                loginuser.Passwordsalt = UpdatedLoginDetails.doc.Passwordsalt;
            }
            if (editDetails.EmailID != "")
            {
                loginuser.EmailID = editDetails.EmailID;
            }
            else
            {
                loginuser.EmailID = UpdatedLoginDetails.doc.EmailID;
            }

            if (editDetails.Type != "")
            {
                loginuser.Type = editDetails.Type;
            }
            else
            {
                loginuser.Type = UpdatedLoginDetails.doc.Type;
            }

            loginuser.Username = UpdatedLoginDetails.doc.Username;
            loginuser._id      = UpdatedLoginDetails.doc._id;
            loginuser.Id       = UpdatedLoginDetails.doc.Id;
            loginuser._rev     = UpdatedLoginDetails.doc._rev;


            if (_postUserLoginProcessor != null)
            {
                return(await _putUserLoginProcessor.PutExistingUserRecord(loginuser, _cloudantService));
            }
            else
            {
                return(new string[] { "No database connection" });
            }
        }