change loginpath for specific user, ASP.Net, webforms

102 views Asked by At

I recently started working on a site that another developer built (who is not within the company anymore, so can't ask him)

On the site there is several separate accounttypes for users, so when a user logs in, the user comes to one of two specified login-start pages.

Some users have two accounttypes. When that's the case I want to make a dropdownlist that holds both startpage-options (let's call them a, and b)

If they choose option a) from the ddl, the a-startpage will be that users permanent startpage until the user changes it to b, then b will be that specific users permanent startpage.

the project is made with C#, ASP.NET, with Webforms, MS SQL.

any suggestions that might lead me in the right direction is much appreciated
/S

2

There are 2 answers

0
2Lach On BEST ANSWER

So in the end i solved it like this.

Firstly i created an int(allows null) column called "changesite" in the db (member/user)table so i could use the members id.

Then i connected it to the dropdownlist where the members/users can choose their startpage (in my case i made the ddl only visible to the members if they are the type of user that has the both user accounts).

if the user chooses the first option a 1 got saved in the db, and for the second option a 2. (This method could be used with any number of startpages you might have).

Then in .cs file were users got redirected to their designated startpage it was as simple as creating an if, else-statement, with the value from changesite as identifier.

Basically if the value from column changesite == null, do nothing. If changesite == 1 redirect to the first startpage and else redirect to the second startpage.

A big thx to Paolo for his inputs.

5
Paolo On

there are at least 2 possible solutions that require little effort:

  • a cookie on the user's system: when accessing the system for the first time (or after a system change or a browser's cookies clearing) the application takes the user to the dropdown page and let the user choose the preferred login-start page. on subsequent accesses the choice is read from the cookie and then the user is forwarded to the expected page.
    the biggest advantage IMHO is that no changes to the backend structure are required and the changes on the fronted are minimal.
    BEWARE: do not trust what you get reading the cookie and always double check that the page suggested by the cookie is actually allowed for the user.
  • an attribute of the user: the user choice is saved in the user's profile and read on subsequent accesses.
    this approach requires some change in the backend because a new attribute must be added to the user entity and maybe also the tools (stored procedure, method, whatever) needed to interact with that new attribute have to be created.
    this solution requires less or no checks/validation because the information is stored server side so you can redirect 'blindly' to the login-start page.

there is not a 'right' solution because it mainly depends on what you are allowed to do and your skills.
are you allwed to alter the backend's structure?
what you know better, backend or frontend development?
which one is easier for you to change?
is there any policy/guideline to follow while developing that favor one of these approaches?