User

Class used to manage one user

Constructors

this
this()
this
this(UserModel userData)
this
this(string email, string password)

Members

Aliases

ChangedEvent
alias ChangedEvent = void delegate(User)

Event type raised when the user data has changed

Functions

addScope
void addScope(string access)

Add a scope to the user

can
bool can()

Check if an user can access a scope

createToken
Token createToken(SysTime expire, string[] scopes, string type, string[string] meta)

Create an user token

getScopes
string[] getScopes(string token)

Get the user scopes assigned to a particullar token

getScopes
string[] getScopes()

Get all user scopes

getTokensByType
auto getTokensByType(string type)

Get a range of tokens of a certain type

isValidPassword
bool isValidPassword(string password)

Validate a password

isValidToken
bool isValidToken(string token)

Validate a token

isValidToken
bool isValidToken(string token, string requiredScope)

Validate a token against a scope

removeExpiredTokens
void removeExpiredTokens()
Undocumented in source. Be warned that the author may not have intended to support it.
removeScope
void removeScope(string access)

Remove a scope from user

revoke
void revoke(string token)

Revoke a token

setPassword
void setPassword(string password)

Change the user password

setPassword
void setPassword(string password, string salt)

Change the user password by providing a salting string

toJson
Json toJson()

Convert the object to a json. It's not safe to share this value with the outside world. Use it to store the user to db.

toPublicJson
Json toPublicJson()

Convert the object to a json that can be shared with the outside world

toString
string toString()

Convert the user object ot a Json pretty string

Properties

email
string email [@property getter]

Get the user email

email
string email [@property setter]

Set the user email

firstName
auto firstName [@property getter]

Get the user first name

firstName
string firstName [@property setter]

Set the user first name

id
auto id [@property getter]

Get the user id

id
ulong id [@property setter]

Set the user id

isActive
bool isActive [@property getter]

Check if the user is active

isActive
bool isActive [@property setter]

Check the user active status

lastActivity
auto lastActivity [@property getter]

Get the last user activity timestamp

lastActivity
ulong lastActivity [@property setter]

Set the last user activity timestam[]

lastName
auto lastName [@property getter]

Get the user last name

lastName
string lastName [@property setter]

Set the user last name

salutation
auto salutation [@property getter]

Get the user title

salutation
string salutation [@property setter]

Set the user title

title
auto title [@property getter]

Get the user title

title
string title [@property setter]

Set the user title

username
auto username [@property getter]

Get the user alias name

username
string username [@property setter]

Set the user alias name

Static functions

fromJson
User fromJson(Json data)

Restore the user from a json value

Variables

onChange
ChangedEvent onChange;

Event raised when the user changed

Meta