class Wikicr::User
- Wikicr::User
- Reference
- Object
Overview
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.
Included Modules
- Acl::Entity
- YAML::Serializable
Defined in:
lib/users/user.crConstructors
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(name : String, password : String, groups : Array(String) = [] of String, token : String | Nil = nil)
Instance Method Summary
-
#encrypt!
Encrypts the passwod using
Crypto::Bcrypt
. - #generate_new_token!
-
#groups : Array(String)
Returns the list of the group names of the
Entity
- #groups=(groups : Array(String))
-
#has_group?(group : String) : Bool
Returns
true
if the group is owned by theEntity
, elsefalse
- #name : String
- #name=(name : String)
- #password : String
- #password=(password : String)
-
#password_encrypted
Reads the password using
Crypto::Bcrypt
- #token : String | Nil
- #token=(token : String | Nil)
Instance methods inherited from module Acl::Entity
groups : Array(String)
groups,
has_group?(group : String) : Bool
has_group?
Constructor Detail
def self.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)
Instance Method Detail
def encrypt!
#
Encrypts the passwod using Crypto::Bcrypt
.
Wikicr::User.new("admin", "password", %w(admin)).encrypt!.password # => "$2a$11$G2i2.Km1DRbJtqDBFRhKXuSn8IwNVt7AypAP328T1OYq0wBugkgCm"
def groups : Array(String)
#
Description copied from module Acl::Entity
Returns the list of the group names of the Entity
def has_group?(group : String) : Bool
#
Description copied from module Acl::Entity
Returns true
if the group is owned by the Entity
, else false