Class User
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
stringA unique key that identifies this User.
password
stringA 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
UriOptional 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
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
Icon
Gets a icon for the view.
public Uri Icon { get; }
Property Value
Key
Gets a unique key that identifies this IUser.
public string Key { get; }
Property Value
Remarks
Also known as nickname.
Name
Gets or sets the name of the user.
public string Name { get; set; }
Property Value
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
stringThe 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
IPermissionThe 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
stringThe 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.