Table of Contents

Class User

Namespace
Loehnert.Lisrt.Users
Assembly
Loehnert.Lisrt.dll

Class for an user, who can be in Groups to have IPermissions.

public class User : IUser, IHasKey
Inheritance
User
Implements
Inherited Members

Constructors

User(string, string, IEnumerable<IStringRule>, Uri)

Initializes a new instance of the User class.

public User(string key, string password, IEnumerable<IStringRule> rules, Uri icon = null)

Parameters

key string

A unique key that identifies this User.

password string

A password which is necessary for CheckPassword(string) and will be set with SetPassword(string, IEnumerable<IStringRule>).

rules IEnumerable<IStringRule>

The IStringRules for setting a password.

icon Uri

Optional icon for the view.

Remarks

A user should be added to the Users.

Exceptions

ArgumentNullException

Thrown when key is null.

FormatException

Thrown when the password cannot be SetPassword(string, IEnumerable<IStringRule>).

Properties

FirstName

Gets or sets the users first name.

public string FirstName { get; set; }

Property Value

string

Remarks

This is just an optional property and can be set.

Groups

Gets the groups the user belongs to.

public KeyItemCollection<IGroup> Groups { get; }

Property Value

KeyItemCollection<IGroup>

Icon

Gets a icon for the view.

public Uri Icon { get; }

Property Value

Uri

Key

Gets a unique key that identifies this IUser.

public string Key { get; }

Property Value

string

Remarks

Also known as nickname.

Name

Gets or sets the name of the user.

public string Name { get; set; }

Property Value

string

Remarks

This is just an optional property and can be set.

Methods

CheckPassword(string)

Checks the password for equality to the user password.

public virtual bool CheckPassword(string password)

Parameters

password string

The password to check.

Returns

bool

True, if it is the correct one.

HasPermission(IPermission)

Gets a value indicating that the user has the requested permission.

public virtual bool HasPermission(IPermission permission)

Parameters

permission IPermission

The requested permission.

Returns

bool

A value indicating that the user has the requested permission.

SetPassword(string, IEnumerable<IStringRule>)

Sets the password.

public virtual bool SetPassword(string password, IEnumerable<IStringRule> rules)

Parameters

password string

The password to set.

rules IEnumerable<IStringRule>

The IStringRules for setting a password.

Returns

bool

True, if setting was successfully.

Remarks

Checks if all rules are true.