class

Wikicr::User

Inherits Acl::Entity / YAML::Serializable / Reference / Object

An User is a couple name/password/groups/token. The name and groups is public, the password and the token are private. The password is used to recognize an user when login in with a form for example. The token is used to recognize an user by a cookie for exemple.

Constructors

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source
new(name : String, password : String, groups : Array(String) = [] of String, token : String | Nil = nil)
User.new "admin", "password", %w(admin user)
User.new "nephos", "password", %w(user guest)
Source
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Instance methods

encrypt!

Encrypts the passwod using Crypto::Bcrypt.

Wikicr::User.new("admin", "password", %w(admin)).encrypt!.password # => "$2a$11$G2i2.Km1DRbJtqDBFRhKXuSn8IwNVt7AypAP328T1OYq0wBugkgCm"
Source
generate_new_token!
Source
groups

Returns the list of the group names of the Entity

Source
groups=(groups : Array(String))
Source
has_group?(group : String) : Bool

Returns true if the group is owned by the Entity, else false

Source
name
Source
name=(name : String)
Source
password
Source
password=(password : String)
Source
password_encrypted

Reads the password using Crypto::Bcrypt

Source
token
Source
token=(token : String | Nil)
Source

Nested types