locked
Current user in MVC RRS feed

  • Question

  • User-1097602101 posted

    Hi, I want to ask how when a user logs on to his system, only his data is displayed. I've created a login page, but it displays all the information available to me, and I only want it to be displayed as information from a table to which other tables are linked via fk key.

    Wednesday, August 21, 2019 12:38 PM

All replies

  • User753101303 posted

    Hi,

    Unclear. A login page usually doesn't show anything but just let the user to enter his id/password. Do you mean once logged, you are missing a WHERE clause in a SQL query ? Usually you get the user identifier for the authenticated user (though the User.Identity.Name property of your controller or some other identifier claim and use that to filter out which info should be shown.

    Edit: or for now your site doesn't even have any authentication option ? Which authentication method are you using?

    Wednesday, August 21, 2019 1:01 PM
  • User-1097602101 posted

    Being logged in does not mean anything, but how to get everyone to log in and if its ID matches the main table as well as the other IDs and show them to me If there is any example where 2-3 tables are linked because I only find examples where there is 1 table.

    Wednesday, August 21, 2019 2:06 PM
  • User475983607 posted

    This is a database design question.  The userId must be linked to records that belong to the user.  Then simply filter the result set by the user ID.

    We cannot see your table design so there is no way to provide any kind of solution.  At this point it seems like you need to rethink the table schema.

    Wednesday, August 21, 2019 2:07 PM
  • User-474980206 posted

    this is called horizontal partitioning. all the users data rows needs a column that identifies which user it belongs to. you then include this column value in a where clause for all queries.

    another approach is to use a document database, and have the documents keyed by user.

    Wednesday, August 21, 2019 8:17 PM
  • User1520731567 posted

    Hi sssaa,

    but it displays all the information available to me, and I only want it to be displayed as information from a table to which other tables are linked via fk key.

    The content displayed on the page depends on what statement you passed to the page in the action.

    You need to filter you data by some linq,such as: where(),groupby()...e.g.

    I suggest you could add breakpoints on your code and select your query SHIFT+F9 to quick watch its value and modify.

    Best Regards.

    Yuki Tao

    Thursday, August 22, 2019 3:16 AM