https://github.com/humansinput/authsystem
Tcl library that handles user authorization and registration. Uses TDBC to access the database.
https://github.com/humansinput/authsystem
Last synced: 5 months ago
JSON representation
Tcl library that handles user authorization and registration. Uses TDBC to access the database.
- Host: GitHub
- URL: https://github.com/humansinput/authsystem
- Owner: humansinput
- Created: 2020-03-27T15:40:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-28T14:38:35.000Z (over 6 years ago)
- Last Synced: 2025-05-16T13:11:51.836Z (about 1 year ago)
- Size: 1.95 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.asciidoc
Awesome Lists containing this project
README
# AuthSystem
A module for use in Tcl 8.5/8.6 programs that provides handy API for creating and authorizating users.
Depends on TDBC (for now) and Tcllib.
## Usage
[squares]
- ``authsys::use ``: Tells AuthSystem to use this TDBC connection to read/write user data from the specified table. The specified table must contain ``authsys_username`` and ``authsystem_password`` columns, while the rest (if any) must be either optional or have a default value.
- ``authsys::register ``: Creates a user with the specified username and password. If a user exists or the username contains invalid characters, an error is thrown.
- ``authsys::passwordcorrect ``: Checks if the specified username and password are correct. If yes, returns ``1``, otherwise, returns ``0``.
- ``authsys::exists ``: Checks if the specified user is already registered. If yes, returns ``1``, otherwise, returns ``0``.
- ``authsys::authtoken []``: Creates an auth token that can be used to create user sessions. Useful for web apps, you should store the returned value as a cookie. By default, the returned token is valid for 3 days, but you can optionally specify a different number of days as the third argument. Returns a string.
- ``authsys::tokencorrect ``: Returns ``1`` if the token is valid, otherwise, returns ``0``.
## Example
See ``demo.tcl`` (requires TDBC Sqlite3 driver to be present on your system to run).
## License
As always, MIT License.