class

Wikicr::Users

Inherits YAML::Serializable / Lockable / Reference / Object

The class Users handles a list of User, with add, remove, update an find operation. An instance of Users must be linked with a file which can be read of updated

TODO: mutex on add/remove/update

Constructors

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source
new(file : String, default : User | Nil = nil)
Source
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Instance methods

[](name : String) : User
Source
[]?(name : String) : User | Nil
Source
add(u : User)

add an user to the list

Source
auth!(name : String, password : String) : User | Nil

Operation read (erase the internal list).

see #auth?

Source
auth?(name : String, password : String) : User | Nil

No file operation.

Finds an user by its name and check the password.

Returns nil if it fails

Source
auth_token!(name : String, token : String) : User | Nil
Source
auth_token?(name : String, token : String) : User | Nil
Source
default
Source
default=(default : User | Nil)
Source
delete(u : User)

Removes an user from the list @see #delete(String)

Source
delete(name : String)

Remove an user from the list

Source
each
Source
file
Source
file=(file : String)
Source
find(name : String) : User

find an user based on its name

Source
find?(name : String) : User | Nil

find an user based on its name

Source
list
Source
list=(list : Hash(String, User))
Source
load!

read the users from the file (erase the modifications !)

Source
map!
Source
register!(name : String, password : String, groups : Array(String) = ["user"] of ::String)

Operation read and write (erase the internal list and the file)

Registers a new user by create a new User with name, password and groups and then update the file with the new list of users.

Source
save!

save the users into the file

Source
update(name : String, u : User)

replace an entry

Source

Nested types