-
Notifications
You must be signed in to change notification settings - Fork 164
AuthUser admin service
The AuthP library contains a IAuthUsersAdminService service that contains various admin features for managing AuthP's users. This page describes these admin features and give you some examples of how they might be used in an application.
NOTE: the code for the AuthRolesAdminService can be found here and has plenty of comments. Also the Example4's AuthUsersController contains a fully working AuthP users admin methods / pages, but you have to log in as '[email protected]' or '[email protected]' to access all the admin features.
Here is a list of the various methods in the IAuthUsersAdminService, with example pages from Example4's AuthUsersController.
The QueryAuthUsers(string dataKey = null) will return an IQueryable<AuthUser> query. If the datakey is null, then the query will include all the AuthUsers in the AuthP's database. But if you provide a datakey it will only return the users in the multi-tenant that matches the datakey. This allows you to create an admin user who can only manage users within a specific multi-tenant group (see the Index method in Example4's AuthUsersController for an example of this approach).
The IQueryable<AuthUser> query allows you to select the specific parts of the AuthUser and its relationships to display to the the admin user. In the Example4 application (which includes multi-tenant) I created a AuthUserDisplay class which returned the user's info, roles and tenant name. The screenshot below shows this listing when logged in as the '[email protected]'.

Things to point out in this screenshot:
- It lists the email & username of each user
- It lists all the Roles of each user
- Because Example4 is using hierarchical multi-tenant database I included the Tenant? column. It you hover / click the YES you get the full name of the tenant.
As you can see, this list of users also contains links to further admin features which are described below. NOTE: the admin links are only shown if your have the correct Role / Permissions.
Sometime you to need to find a user via a string, say for showing data about a specific user. The IAuthUsersAdminService has two methods to do this, which are: FindAuthUserByUserIdAsync(string userId) and FindAuthUserByEmailAsync(string email).
Both methods return a Task<IStatusGeneric<AuthUser>> result. If there are no errors (such as can't find the user), then you get the AuthUser with its UserRoles and UserTenant.
In the AuthUser explained section authentication provider's users are the master list of users. This means AuthP' user admin doesn't have a 'create a new AuthUser' method, but it has a
- Intro to multi-tenants (ASP.NET video)
- Articles in date order:
- 0. Improved Roles/Permissions
- 1. Setting up the database
- 2. Admin: adding users and tenants
- 3. Versioning your app
- 4. Hierarchical multi-tenant
- 5. Advanced technique with claims
- 6. Sharding multi-tenant setup
- 7. Three ways to add new users
- 8. The design of the sharding data
- 9. Down for maintenance article
- 10: Three ways to refresh claims
- 11. Features of Multilingual service
- 12. Custom databases - Part1
- Videos (old)
- Authentication explained
- Permissions explained
- Roles explained
- AuthUser explained
- Multi tenant explained
- Sharding explained
- How AuthP handles sharding
- How AuthP handles errors
- Languages & cultures explained
- JWT Token refresh explained
- Setup Permissions
- Setup Authentication
- Startup code
- Setup the custom database feature
- JWT Token configuration
- Multi tenant configuration
- Using Permissions
- Using JWT Tokens
- Creating a multi-tenant app
- Supporting multiple languages
- Unit Test your AuthP app