Simple instructions based on Moss tutorial on how it was created up until this particular point If you use this repo, delete mdf in AppData if it exists in order to recreate the database based on our custom seed migrations
Pending:
- Add Models
- Create Role Management Class
- Add authorization tokens
- Apply filters
- Create separate Role views
- maybe more cant think rn
Steps: (Read comments)
- Enable Migrations
- Account Controller -> Register Action 3)Change authorization to the entire webApp
- AppStart -> FilterConfig-> add to method Line "filters.Add(new AuthorizeAttribute());" Change authorization to the entire webApp
- Go to Home Controller and add above the home controller class and inside the name space the
tag [AllowAnonymous]
6)add-migration and update-database
7)ctrl + f5 to register a guest account
credentials: Email:guest@usernroles.com Password: Guest202! - Close browser/stop app
- Go to AccountController in the Register section (Async) inside the "if" clause and add the temporary code
- Ctrl+f5 and register the administrator user with the following credentials: Email: UserNRoles@usernroles.com Password: RolesAdministrator202!
- add-migration originalUsersQuery. we will use this empty migration to use as a vessel for an SQL query for the original Users (Guest, Administrator)
- Go to Solution Explorer-> show all files on top->Go to AppData->Double click the name of the database (UserNRolesBase) wait for loading, rr if needed
- Inside Server explorer expand the database and under tables find the AspNetUsers table -> right click-> show table data
- Click on the bar on the left of the row of the table to select the entire row. Select with ctrl both rows (guest and admin)--> right click and sript
- Go to our empty migration from step 11 and copy the script and paste it inside the up method (inside the string quotes in Sql(@"");)
- repeat steps 13-15 for the AspnetRoles Table this time
- Lastly repeat steps 13-15 for the AspnetUserRoles Table
- Now go to tables AspNetUsers and AspNetRoles one at a time and delete the rows of the tables
- update-database (now our database is ready,we have an administrator, no deleting migrations and tables from now on) All the previous steps are intended to reduce vulnerability
- Go to solution explorer Account Controller and repeat steps 9 and 10 but this time changing the "Administrator" string to Manager in order to create the Manager Role
- ctrl+f5 to register the Manager with credentials: Email:ApplicationManager@usernroles.com Password: ApplicationManager202! Log off and close app
- repeat step 21 for Validated Role Email: FirstValidatedUser@usernroles.com Password: FirstValidatedUser202!
- repeat step 21 for Unvalidated Role Email: FirstUnvalidatedUser@usernroles.com Password: FirstUnvalidatedUser202!