C# Class Roadkill.Core.Security.FormsAuthUserService

Provides user management using the Roadkill datastore and the current repository.
Inheritance: Roadkill.Core.Security.UserServiceBase
Afficher le fichier Open project: LocalGovDigital/pipeline Class Usage Examples

Méthodes publiques

Méthode Description
ActivateUser ( string activationKey ) : bool

Activates the user with given activation key

AddUser ( string email, string username, string password, bool isAdmin, bool isEditor ) : bool

Adds a user to the system, and sets the User.IsActivated to true.

Authenticate ( string email, string password ) : bool

Authenticates the user with the specified email.

ChangePassword ( string email, string oldPassword, string newPassword ) : bool

Changes the password of the user with the given email, authenticating their password first..

ChangePassword ( string email, string newPassword ) : void

Changes the password of a user with the given email.

DeleteUser ( string email ) : bool

Deletes a user with the given email from the system.

FormsAuthUserService ( Roadkill.Core.Configuration.ApplicationSettings settings, IRepository repository ) : System
GetLoggedInUser ( string cookieValue ) : User

Gets the currently logged in user, based off the cookie or HttpContext user identity value set during authentication. The value for FormsAuthentication is the user's Guid id.

GetLoggedInUserName ( System.Web.HttpContextBase context ) : string

Gets the current username by decrypting the cookie. If FormsAuthentication is disabled or there is no logged in user, this returns an empty string.

GetUser ( string email, bool isActivated = null ) : User

Retrieves a full User object for the email address provided, or null if the user doesn't exist.

GetUserById ( System.Guid id, bool isActivated = null ) : User

Retrieves a full User object using the unique ID provided.

GetUserByResetKey ( string resetKey ) : User

Retrieves a full User object for a password reset request.

IsAdmin ( string cookieValue ) : bool

Determines whether the specified user with the given email is an admin.

IsEditor ( string cookieValue ) : bool

Determines whether the specified user with the given email is an editor.

ListAdmins ( ) : IEnumerable

Lists all admins in the system.

ListEditors ( ) : IEnumerable

Lists all editors in the system.

Logout ( ) : void

Signs the user out with (typically with FormsAuthentication).

ResetPassword ( string email ) : string

Resets the password for the user with the given email.

Signup ( UserViewModel model, System.Action completed ) : string

Creates a user in the system without setting the User.IsActivated, in other words for a user confirmation email.

ToggleAdmin ( string email ) : void

Adds or remove the user with the email address as an admin.

ToggleEditor ( string email ) : void

Adds or remove the user with the email address as an editor.

UpdateUser ( UserViewModel model ) : bool

Changes the username of a user to a new username.

UserExists ( string email ) : bool

Determines whether the user with the given email exists.

UserNameExists ( string username ) : bool

Determines whether the user with the given username exists.

Method Details

ActivateUser() public méthode

Activates the user with given activation key
public ActivateUser ( string activationKey ) : bool
activationKey string The randomly generated activation key for the user.
Résultat bool

AddUser() public méthode

Adds a user to the system, and sets the User.IsActivated to true.
An databaseerror occurred while adding the new user.
public AddUser ( string email, string username, string password, bool isAdmin, bool isEditor ) : bool
email string The email or username.
username string
password string The password.
isAdmin bool if set to true the user is added as an admin.
isEditor bool if set to true the user is added as an editor.
Résultat bool

Authenticate() public méthode

Authenticates the user with the specified email.
An databaseerror occurred while authenticating the user.
public Authenticate ( string email, string password ) : bool
email string The email address or username of the user.
password string The password.
Résultat bool

ChangePassword() public méthode

Changes the password of the user with the given email, authenticating their password first..
An databaseerror occurred while changing the password OR the new password is empty.
public ChangePassword ( string email, string oldPassword, string newPassword ) : bool
email string The email address or username of the user.
oldPassword string The old password.
newPassword string The new password to change to.
Résultat bool

ChangePassword() public méthode

Changes the password of a user with the given email.
An databaseerror occurred while changing the password OR the password is empty.
public ChangePassword ( string email, string newPassword ) : void
email string The email address of the user.
newPassword string The new password.
Résultat void

DeleteUser() public méthode

Deletes a user with the given email from the system.
An databaseerror occurred while deleting the user.
public DeleteUser ( string email ) : bool
email string The email address or username of the user.
Résultat bool

FormsAuthUserService() public méthode

public FormsAuthUserService ( Roadkill.Core.Configuration.ApplicationSettings settings, IRepository repository ) : System
settings Roadkill.Core.Configuration.ApplicationSettings
repository IRepository
Résultat System

GetLoggedInUser() public méthode

Gets the currently logged in user, based off the cookie or HttpContext user identity value set during authentication. The value for FormsAuthentication is the user's Guid id.
public GetLoggedInUser ( string cookieValue ) : User
cookieValue string The user id stored in the cookie.
Résultat Roadkill.Core.Database.User

GetLoggedInUserName() public méthode

Gets the current username by decrypting the cookie. If FormsAuthentication is disabled or there is no logged in user, this returns an empty string.
public GetLoggedInUserName ( System.Web.HttpContextBase context ) : string
context System.Web.HttpContextBase
Résultat string

GetUser() public méthode

Retrieves a full User object for the email address provided, or null if the user doesn't exist.
public GetUser ( string email, bool isActivated = null ) : User
email string The email address of the user to get
isActivated bool
Résultat Roadkill.Core.Database.User

GetUserById() public méthode

Retrieves a full User object using the unique ID provided.
public GetUserById ( System.Guid id, bool isActivated = null ) : User
id System.Guid The ID of the user.
isActivated bool
Résultat Roadkill.Core.Database.User

GetUserByResetKey() public méthode

Retrieves a full User object for a password reset request.
public GetUserByResetKey ( string resetKey ) : User
resetKey string
Résultat Roadkill.Core.Database.User

IsAdmin() public méthode

Determines whether the specified user with the given email is an admin.
An databaseerror occurred while email/username.
public IsAdmin ( string cookieValue ) : bool
cookieValue string The user id or username of the user.
Résultat bool

IsEditor() public méthode

Determines whether the specified user with the given email is an editor.
An databaseerror occurred while checking email/username.
public IsEditor ( string cookieValue ) : bool
cookieValue string The user id or username of the user.
Résultat bool

ListAdmins() public méthode

Lists all admins in the system.
An databaseerror occurred while getting the admins.
public ListAdmins ( ) : IEnumerable
Résultat IEnumerable

ListEditors() public méthode

Lists all editors in the system.
An databaseerror occurred while getting the editors.
public ListEditors ( ) : IEnumerable
Résultat IEnumerable

Logout() public méthode

Signs the user out with (typically with FormsAuthentication).
public Logout ( ) : void
Résultat void

ResetPassword() public méthode

Resets the password for the user with the given email.
public ResetPassword ( string email ) : string
email string The email address or username of the user.
Résultat string

Signup() public méthode

Creates a user in the system without setting the User.IsActivated, in other words for a user confirmation email.
public Signup ( UserViewModel model, System.Action completed ) : string
model UserViewModel
completed System.Action Called once the signup (e.g. email is sent) is complete. Pass Null for no action.
Résultat string

ToggleAdmin() public méthode

Adds or remove the user with the email address as an admin.
An databaseerror occurred while setting the user to an admin.
public ToggleAdmin ( string email ) : void
email string The email address or username of the user.
Résultat void

ToggleEditor() public méthode

Adds or remove the user with the email address as an editor.
An databaseerror occurred while setting the user to an editor.
public ToggleEditor ( string email ) : void
email string The email address or username of the user.
Résultat void

UpdateUser() public méthode

Changes the username of a user to a new username.
An databaseerror occurred while changing the email/username.
public UpdateUser ( UserViewModel model ) : bool
model UserViewModel The user details to change. The password property is ignored for this object - use ChangePassword instead.
Résultat bool

UserExists() public méthode

Determines whether the user with the given email exists.
An databaseerror occurred while checking the email/user.
public UserExists ( string email ) : bool
email string The email address or username of the user.
Résultat bool

UserNameExists() public méthode

Determines whether the user with the given username exists.
public UserNameExists ( string username ) : bool
username string
Résultat bool