class Wikicr::User

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

Defined in:

lib/users/user.cr

Constructors

Instance Method Summary

Instance methods inherited from module Acl::Entity

groups : Array(String) groups, has_group?(group : String) : Bool has_group?

Constructor Detail

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

[View source]
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)

[View source]

Instance Method Detail

def encrypt! #

Encrypts the passwod using Crypto::Bcrypt.

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

[View source]
def generate_new_token! #

[View source]
def groups : Array(String) #
Description copied from module Acl::Entity

Returns the list of the group names of the Entity


[View source]
def groups=(groups : Array(String)) #

[View source]
def has_group?(group : String) : Bool #
Description copied from module Acl::Entity

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


[View source]
def name : String #

[View source]
def name=(name : String) #

[View source]
def password : String #

[View source]
def password=(password : String) #

[View source]
def password_encrypted #

Reads the password using Crypto::Bcrypt


[View source]
def token : String | Nil #

[View source]
def token=(token : String | Nil) #

[View source]