class Wikicr::Users
- Wikicr::Users
- Lockable
- Reference
- Object
Overview
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
Included Modules
- YAML::Serializable
Defined in:
lib/users/users.crConstructors
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(file : String, default : User | Nil = nil)
Instance Method Summary
- #[](name : String) : User
- #[]?(name : String) : User | Nil
-
#add(u : User)
add an user to the list
-
#auth!(name : String, password : String) : User | Nil
Operation read (erase the internal list).
-
#auth?(name : String, password : String) : User | Nil
No file operation.
- #auth_token!(name : String, token : String) : User | Nil
- #auth_token?(name : String, token : String) : User | Nil
- #default : User | Nil
- #default=(default : User | Nil)
-
#delete(u : User)
Removes an user from the list @see #delete(String)
-
#delete(name : String)
Remove an user from the list
- #each(&)
- #file : String
- #file=(file : String)
-
#find(name : String) : User
find an user based on its name
-
#find?(name : String) : User | Nil
find an user based on its name
- #list : Hash(String, User)
- #list=(list : Hash(String, User))
-
#load!
read the users from the file (erase the modifications !)
- #map(&)
- #map!(&)
-
#register!(name : String, password : String, groups : Array(String) = ["user"] of ::String)
Operation read and write (erase the internal list and the file)
-
#save!
save the users into the file
-
#update(name : String, u : User)
replace an entry
Instance methods inherited from class Lockable
load!
load!,
save!
save!,
transaction!(read = false, &)
transaction!
Constructor Detail
Instance Method Detail
Operation read (erase the internal list).
see #auth?
No file operation.
Finds an user by its name and check the password.
Returns nil if it fails
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.