2021-07-17 15:46:23 +00:00
|
|
|
# Chat Registration System
|
|
|
|
|
|
|
|
The basic backend code needed to register & login to a chat system (to be built).
|
|
|
|
Send it the unhashed username and pin, and it'll store it in the `users.json` file with the pin hashed with SHA1.
|
|
|
|
|
|
|
|
## API Documentation
|
|
|
|
|
2021-07-17 19:59:58 +00:00
|
|
|
`POST /api/register/<name>/<pin>/<pronouns>` Register the username with the pin provided if it doesn't already exist
|
2021-07-18 16:06:05 +00:00
|
|
|
Returns status & reason json.
|
2021-07-16 14:55:07 +00:00
|
|
|
|
|
|
|
`GET /api/users/<name>` Check if the user exists
|
2021-07-18 16:06:05 +00:00
|
|
|
Returns either
|
|
|
|
|
|
|
|
`{
|
|
|
|
"status": "fail",
|
|
|
|
"reason": "user not found",
|
|
|
|
}`
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
`{
|
|
|
|
"status": "ok",
|
|
|
|
"user": {
|
|
|
|
"name": "<name>",
|
|
|
|
"pronouns": "<pronouns>",
|
|
|
|
},
|
|
|
|
}`
|
2021-07-16 14:55:07 +00:00
|
|
|
|
|
|
|
`GET /api/users/<name>/<pin>` Check if the user exists, and if the pin provided matches
|
2021-07-18 16:06:05 +00:00
|
|
|
Returns status & reason json.
|
2021-07-16 14:55:07 +00:00
|
|
|
|
2021-07-16 17:37:25 +00:00
|
|
|
`POST /api/users/change/<name>/<pin>/<new-name>/<new-pin>` Change a users pin/name
|
2021-07-18 16:06:05 +00:00
|
|
|
Returns status & reason json.
|
|
|
|
|
|
|
|
|
|
|
|
## Chat Documentation
|
2021-07-17 19:52:52 +00:00
|
|
|
|
2021-07-18 16:06:05 +00:00
|
|
|
`POST /api/message/send {"name":"username","body":"message body","date":"yyy-mm-dd","token":"USER_TOKEN"}` Post a json message.
|
|
|
|
Returns status & reason json.
|
2021-07-17 19:59:58 +00:00
|
|
|
|
2021-07-18 16:06:05 +00:00
|
|
|
`GET /api/message/messages.json` Get a json file of all the messages
|
2021-07-17 19:59:58 +00:00
|
|
|
|
2021-07-17 19:52:52 +00:00
|
|
|
## Chat Planning
|
|
|
|
|
|
|
|
Clientside js will register & check login of users, if login is correct will ask for a random token.
|
|
|
|
Backend will generate token, store it, and then send it to the client to set as a cookie.
|
|
|
|
Whenever user sends a message, client will send message & token and backend will check if token matches.
|
|
|
|
|
|
|
|
## To-Do:
|
|
|
|
|
2021-07-18 16:06:05 +00:00
|
|
|
- [x] Basic auth API
|
2021-07-18 14:16:55 +00:00
|
|
|
- [ ] Return json instead of string
|
2021-07-18 16:06:05 +00:00
|
|
|
- "status" shows wether request was succesful or not, either "ok" or "fail"
|
|
|
|
- "reason" is for more details, mainly just for debugging?
|
|
|
|
- [x] Basic messaging system
|
2021-07-18 15:37:11 +00:00
|
|
|
- [x] Finish up `chat::create_message()`
|
|
|
|
- [x] Create `chat::fetch_messages()`
|
2021-07-18 02:27:05 +00:00
|
|
|
- [ ] Create `chat::delete_message()`
|
2021-07-17 19:52:52 +00:00
|
|
|
- [ ] Token generation & storage
|
2021-07-18 02:27:05 +00:00
|
|
|
- [ ] API to refresh token
|
|
|
|
- [ ] Store token in json
|
|
|
|
- [ ] API to check token?
|
2021-07-17 19:52:52 +00:00
|
|
|
- [x] Pronouns
|
2021-07-18 16:06:05 +00:00
|
|
|
- [x] Set pronouns
|
2021-07-18 02:27:05 +00:00
|
|
|
- [ ] Change pronouns
|
|
|
|
- [ ] Multiple sets of pronouns
|
|
|
|
- [ ] Some form of plural support?
|
2021-07-17 23:41:41 +00:00
|
|
|
- [ ] User management (banning, etc.)
|
|
|
|
- [ ] Blacklist words from chat/names
|
2021-07-18 16:06:05 +00:00
|
|
|
- [ ] More advanced chat features
|
|
|
|
- [ ] Different types of message events? eg. default, announcement, command
|
|
|
|
- [ ] Emote support?
|