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)
Sourcenew(file : String, default : User | Nil = nil)
Sourcenew(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
SourceInstance methods
[](name : String) : User
Source[]?(name : String) : User | Nil
Sourceauth!(name : String, password : String) : User | Nil
Operation read (erase the internal list).
see #auth?
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
auth_token!(name : String, token : String) : User | Nil
Sourceauth_token?(name : String, token : String) : User | Nil
Sourcedefault
Sourcedefault=(default : User | Nil)
Sourceeach
Sourcefile
Sourcefile=(file : String)
Sourcelist
Sourcelist=(list : Hash(String, User))
Sourcemap
Sourcemap!
Sourceregister!(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.