Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Enable user only to update their own credentials

$
0
0

Hi guys,

I'm creating an authenticated WPF application. I have used this custom authentication to help me achieve this. However, as part of my application, I have two types of users; a Staff and a Admin. Both of which have different permissions (Adminusers can update and edit everything while Staff can only view). Furthermore, I also have a view that populates a listview with all the users, enabling them to be edited or delete, shown below;

However, this just shows all the users. I use the following code to get the users from the database;

public List<DataObjects.User> GetUsers() { using (var context = new DBEntities()) { return context.Users.ToList<DataObjects.User>(); } }

//...VM...

// within the constructor

UserList = new ObservableCollection<UserViewModel>(GetUsers());

internal ObservableCollection<UserViewModel> GetUsers()
        {
            if (userList == null)
                userList = new ObservableCollection<UserViewModel>();
            userList.Clear();

            foreach (DataObjects.User i in new UserRepository().GetUsers())
            {
                UserViewModel c = new UserViewModel(i);
                userList.Add(c);
            }
            return userList;
        }

        private ObservableCollection<UserViewModel> userList = null;
        public ObservableCollection<UserViewModel> UserList
        {
            get
            {
                return userList;
            }
            set
            {
                userList = value;
                OnPropertyChanged("UserList");
            }
        }


But my question is; Is there a way to only display the user from the one who logged into the application to enable them to update their own password is needs be; rather then all the users details being displayed all at once?

Many thanks,

Greg.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>