简体   繁体   中英

How do I display a list of users and an option to change their passwords?

I have a need to create a simple user administration page where I can simply show a list of users and change their passwords. The application isn't very big so there are only a handful of users using the system but like any infrastructure they sometimes forget what their passwords are. I need a simple solution to do this.

I created an Admin controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyProject.Models;
using MyProject.ViewModels;
using Microsoft.AspNet.Identity.EntityFramework;

namespace MyProject.Controllers
{
    public class AdminController : Controller
    {

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Users()
        {
           var context = new ApplicationDbContext(); 
           var allusers = context.Users;
           return View(allusers);
        }
    }
}

I need some help retuning this list to a view and also creating the crucial password reset part as well. There seem to be quite a few different ways of doing this so I'm a bit confused as to how I can approach it.

rly Admin can change passwords ?

here i found some code

maybe will help

You are using default login and register from asp.net ? Why u want to add useless functionality like admin changing passwords ? I will suggest to do more complex staff :) Use EntityFramework and generate user Table and when someone register add him to this table. Then when you are in Admin Panel get data from that table and display it. Because when user login they can manage own account( including password)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM