IUserRepository<TId>
Members
Namespace: ASPSecurityKit
Assembly: ASPSecurityKit.dll
Summary
Provides an abstraction to implement a repository for IUser<TId> in the database/ORM technology of your choice.
Generic Types
Name | Description |
---|---|
TId | Type of key identifier used in the application. |
Methods
GetNewUser()
Summary
Gets an instance of a new IUser<TId> object.
Returns
AN empty instance of IUser<TId>.
Parameters
This method has no parameters.
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserById(id)
Summary
Gets the IUser<TId> object associated with the specified id.
Returns
The IUser<TId> object associated with the specified id.
Parameters
Name | Type | Description |
---|---|---|
id | TId | Identifier associated with the user to retrieve. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserByUsername(username)
Summary
Gets the IUser<TId> object associated with the specified username.
Returns
The IUser<TId> object associated with the specified username.
Parameters
Name | Type | Description |
---|---|---|
username | System.String | Username associated with the user to retrieve. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
LoadUser(username)
Summary
Gets the IUser<TId> object associated with the specified username.
Returns
The IUser<TId> object associated with the specified username.
Parameters
Name | Type | Description |
---|---|---|
username | System.String | Username associated with the user to retrieve. |
Remarks
This method is called when user data is to be loaded into session after authentication or session_start (by Login, Load respectively). By separating this method from GetUserByUsername, it has been made explicit that an authenticated user session has begun and you should load related data to IUser<TId>. The returned object must implement IUser<TId> and not just IUser.
LoadUser(id)
Summary
Gets the IUser<TId> object associated with the specified id.
Returns
The IUser<TId> object associated with the specified id.
Parameters
Name | Type | Description |
---|---|---|
id | TId | Identifier associated with the user to retrieve. |
Remarks
This method is called when user data is to be loaded into session after authentication or session_start (by Login, Load respectively). By separating this method from GetUserById, it has been made explicit that an authenticated user session has begun and you should load related data to IUser<TId>. The returned object must implement IUser<TId> and not just IUser.
LoadFakeUser(auth)
Summary
Gets a dummy (fake) IUser<TId> object for identity tokens not associated with any user.
Returns
The dummy (fake) IUser<TId> object for identity tokens not associated with any user.
Parameters
Name | Type | Description |
---|---|---|
auth | ASPSecurityKit.IAuthDetails | Details related to the current identity. Though not consequential, yet may be helpful if needed to load specific values based on permissions granted to the token. |
Remarks
This method is called when new identity is being loaded (after successful authentication) by Load. The identity token doesn’t have any associated user and hence we need to load a dummy user to prevent issues in consumers which depend on CurrentUser and related user properties. The returned object must implement IUser<TId> and not just IUser.
GetUserByVerificationToken(token)
Summary
Gets the IUser<TId> object that has the specified verification token.
Returns
The IUser<TId> object that has the specified verification token.
Parameters
Name | Type | Description |
---|---|---|
token | System.String | Verification token associated with the user to retrieve. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserByPasswordResetToken(token)
Summary
Gets the IUser<TId> object that has the specified password reset token.
Returns
The IUser<TId> object that has the specified password reset token.
Parameters
Name | Type | Description |
---|---|---|
token | System.String | Password reset token associated with the user to retrieve. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
AddUser(model)
Summary
Adds a new user to the database.
Returns
true
if user is successfully added; otherwise, false
.
Parameters
Name | Type | Description |
---|---|---|
model | ASPSecurityKit.IUser | The user model. |
Remarks
Note to implementers: you must return false if user with the specified username already exists. for any other issue, you should throw exception.
UpdateUser(model)
Summary
Saves changes made to an existing user model into the database.
Returns
true
if update was successful; false
if uniqueness was violated. Throw exception otherwise.
Parameters
Name | Type | Description |
---|---|---|
model | ASPSecurityKit.IUser | The user model that is updated. |
Remarks
Note to implementers: you must return false rather than throwing exception in cases when key violation (unique constraint violated) occurs.
GetUserByIdAsync(id)
Summary
Gets the IUser<TId> object associated with the specified id.
Returns
The IUser<TId> object associated with the specified id.
Parameters
Name | Type | Description |
---|---|---|
id | TId | Identifier associated with the user to retrieve. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserByIdAsync(id,cancellationToken)
Summary
Gets the IUser<TId> object associated with the specified id.
Returns
The IUser<TId> object associated with the specified id.
Parameters
Name | Type | Description |
---|---|---|
id | TId | Identifier associated with the user to retrieve. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserByUsernameAsync(username)
Summary
Gets the IUser<TId> object associated with the specified username.
Returns
The IUser<TId> object associated with the specified username.
Parameters
Name | Type | Description |
---|---|---|
username | System.String | Username associated with the user to retrieve. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserByUsernameAsync(username,cancellationToken)
Summary
Gets the IUser<TId> object associated with the specified username.
Returns
The IUser<TId> object associated with the specified username.
Parameters
Name | Type | Description |
---|---|---|
username | System.String | Username associated with the user to retrieve. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
LoadUserAsync(username)
Summary
Gets the IUser<TId> object associated with the specified username.
Returns
The IUser<TId> object associated with the specified username.
Parameters
Name | Type | Description |
---|---|---|
username | System.String | Username associated with the user to retrieve. |
Remarks
This method is called when user data is to be loaded into session after authentication or session_start (by Login, Load respectively). By separating this method from GetUserByUsername, it has been made explicit that an authenticated user session has begun and you should load related data to IUser<TId>. The returned object must implement IUser<TId> and not just IUser.
LoadUserAsync(username,cancellationToken)
Summary
Gets the IUser<TId> object associated with the specified username.
Returns
The IUser<TId> object associated with the specified username.
Parameters
Name | Type | Description |
---|---|---|
username | System.String | Username associated with the user to retrieve. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
This method is called when user data is to be loaded into session after authentication or session_start (by Login, Load respectively). By separating this method from GetUserByUsername, it has been made explicit that an authenticated user session has begun and you should load related data to IUser<TId>. The returned object must implement IUser<TId> and not just IUser.
LoadUserAsync(id)
Summary
Gets the IUser<TId> object associated with the specified id.
Returns
The IUser<TId> object associated with the specified id.
Parameters
Name | Type | Description |
---|---|---|
id | TId | Identifier associated with the user to retrieve. |
Remarks
This method is called when user data is to be loaded into session after authentication or session_start (by Login, Load respectively). By separating this method from GetUserById, it has been made explicit that an authenticated user session has begun and you should load related data to IUser<TId>. The returned object must implement IUser<TId> and not just IUser.
LoadUserAsync(id,cancellationToken)
Summary
Gets the IUser<TId> object associated with the specified id.
Returns
The IUser<TId> object associated with the specified id.
Parameters
Name | Type | Description |
---|---|---|
id | TId | Identifier associated with the user to retrieve. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
This method is called when user data is to be loaded into session after authentication or session_start (by Login, Load respectively). By separating this method from GetUserById, it has been made explicit that an authenticated user session has begun and you should load related data to IUser<TId>. The returned object must implement IUser<TId> and not just IUser.
LoadFakeUserAsync(auth)
Summary
Gets a dummy (fake) IUser<TId> object for identity tokens not associated with any user.
Returns
The dummy (fake) IUser<TId> object for identity tokens not associated with any user.
Parameters
Name | Type | Description |
---|---|---|
auth | ASPSecurityKit.IAuthDetails | Details related to the current identity. Though not consequential, yet may be helpful if needed to load specific values based on permissions granted to the token. |
Remarks
This method is called when new identity is being loaded (after successful authentication) by Load. The identity token doesn’t have any associated user and hence we need to load a dummy user to prevent issues in consumers which depend on CurrentUser and related user properties. The returned object must implement IUser<TId> and not just IUser.
LoadFakeUserAsync(auth,cancellationToken)
Summary
Gets a dummy (fake) IUser<TId> object for identity tokens not associated with any user.
Returns
The dummy (fake) IUser<TId> object for identity tokens not associated with any user.
Parameters
Name | Type | Description |
---|---|---|
auth | ASPSecurityKit.IAuthDetails | Details related to the current identity. Though not consequential, yet may be helpful if needed to load specific values based on permissions granted to the token. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
This method is called when new identity is being loaded (after successful authentication) by Load. The identity token doesn’t have any associated user and hence we need to load a dummy user to prevent issues in consumers which depend on CurrentUser and related user properties. The returned object must implement IUser<TId> and not just IUser.
GetUserByVerificationTokenAsync(token)
Summary
Gets the IUser<TId> object that has the specified verification token.
Returns
The IUser<TId> object that has the specified verification token.
Parameters
Name | Type | Description |
---|---|---|
token | System.String | Verification token associated with the user to retrieve. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserByVerificationTokenAsync(token,cancellationToken)
Summary
Gets the IUser<TId> object that has the specified verification token.
Returns
The IUser<TId> object that has the specified verification token.
Parameters
Name | Type | Description |
---|---|---|
token | System.String | Verification token associated with the user to retrieve. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserByPasswordResetTokenAsync(token)
Summary
Gets the IUser<TId> object that has the specified password reset token.
Returns
The IUser<TId> object that has the specified password reset token.
Parameters
Name | Type | Description |
---|---|---|
token | System.String | Password reset token associated with the user to retrieve. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
GetUserByPasswordResetTokenAsync(token,cancellationToken)
Summary
Gets the IUser<TId> object that has the specified password reset token.
Returns
The IUser<TId> object that has the specified password reset token.
Parameters
Name | Type | Description |
---|---|---|
token | System.String | Password reset token associated with the user to retrieve. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
The returned object must implement IUser<TId> and not just IUser.
AddUserAsync(model)
Summary
Adds a new user to the database.
Returns
true
if user is successfully added; otherwise, false
.
Parameters
Name | Type | Description |
---|---|---|
model | ASPSecurityKit.IUser | The user model. |
Remarks
Note to implementers: you must return false if user with the specified username already exists. for any other issue, you should throw exception.
AddUserAsync(model,cancellationToken)
Summary
Adds a new user to the database.
Returns
true
if user is successfully added; otherwise, false
.
Parameters
Name | Type | Description |
---|---|---|
model | ASPSecurityKit.IUser | The user model. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
Note to implementers: you must return false if user with the specified username already exists. for any other issue, you should throw exception.
UpdateUserAsync(model)
Summary
Saves changes made to an existing user model into the database.
Returns
true
if update was successful; false
if uniqueness was violated. Throw exception otherwise.
Parameters
Name | Type | Description |
---|---|---|
model | ASPSecurityKit.IUser | The user model that is updated. |
Remarks
Note to implementers: you must return false rather than throwing exception in cases when key violation (unique constraint violated) occurs.
UpdateUserAsync(model,cancellationToken)
Summary
Saves changes made to an existing user model into the database.
Returns
true
if update was successful; false
if uniqueness was violated. Throw exception otherwise.
Parameters
Name | Type | Description |
---|---|---|
model | ASPSecurityKit.IUser | The user model that is updated. |
cancellationToken | System.Threading.CancellationToken | The cancellation token. |
Remarks
Note to implementers: you must return false rather than throwing exception in cases when key violation (unique constraint violated) occurs.