C# Class Roadkill.Core.Security.FormsAuthUserService

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

Public Methods

Method 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 method

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

AddUser() public method

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.
return bool

Authenticate() public method

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.
return bool

ChangePassword() public method

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.
return bool

ChangePassword() public method

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.
return void

DeleteUser() public method

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.
return bool

FormsAuthUserService() public method

public FormsAuthUserService ( Roadkill.Core.Configuration.ApplicationSettings settings, IRepository repository ) : System
settings Roadkill.Core.Configuration.ApplicationSettings
repository IRepository
return System

GetLoggedInUser() public method

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.
return Roadkill.Core.Database.User

GetLoggedInUserName() public method

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
return string

GetUser() public method

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
return Roadkill.Core.Database.User

GetUserById() public method

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
return Roadkill.Core.Database.User

GetUserByResetKey() public method

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

IsAdmin() public method

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.
return bool

IsEditor() public method

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.
return bool

ListAdmins() public method

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

ListEditors() public method

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

Logout() public method

Signs the user out with (typically with FormsAuthentication).
public Logout ( ) : void
return void

ResetPassword() public method

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.
return string

Signup() public method

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.
return string

ToggleAdmin() public method

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.
return void

ToggleEditor() public method

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.
return void

UpdateUser() public method

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.
return bool

UserExists() public method

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.
return bool

UserNameExists() public method

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