Skip to content

Commit 22ae293

Browse files
committed
stage 1 of desktop rewrite
1 parent 59de5c0 commit 22ae293

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2014
-1357
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Python cache
1+
# Cache
2+
bun.lockb
23
__pycache__/
34

45
# Hide venvs

nightwatch/auth/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import secrets
55

66
from fastapi import FastAPI
7+
from fastapi.middleware.cors import CORSMiddleware
78

89
import argon2
910
from fastapi.responses import JSONResponse
@@ -18,6 +19,13 @@
1819
class AuthenticationServer(FastAPI):
1920
def __init__(self) -> None:
2021
super().__init__()
22+
self.add_middleware(
23+
CORSMiddleware,
24+
allow_origins = "*",
25+
allow_credentials = True,
26+
allow_methods = ["POST"],
27+
allow_headers = ["*"]
28+
)
2129

2230
# Initialize Argon2
2331
self.hasher = argon2.PasswordHasher()
@@ -39,7 +47,9 @@ def __init__(self) -> None:
3947
async def route_api_profile(payload: models.BaseTokenModel) -> JSONResponse:
4048
"""Fetches a users profile. This method is POST to prevent query strings with account tokens
4149
from being logged via uvicorn or whatever HTTP server is running at the moment."""
42-
response: dict | None = app.db.tokens.find_one(filter = {"token": payload.token.get_secret_value()})
50+
response: dict | None = app.db.tokens.find_one(filter = {"token": payload.token.get_secret_value()}) or \
51+
app.db.users.find_one(filter = {"token": payload.token.get_secret_value()})
52+
4353
if response is None:
4454
return JSONResponse(
4555
content = {"code": 403, "data": "Invalid account token."},
@@ -57,7 +67,7 @@ async def route_api_authorize(payload: models.AuthorizeModel) -> JSONResponse:
5767
response: dict | None = app.db.users.find_one(filter = {"token": payload.token.get_secret_value()})
5868
if response is None:
5969
return JSONResponse(
60-
content = {"comde": 403, "data": "Invalid account token."},
70+
content = {"code": 403, "data": "Invalid account token."},
6171
status_code = 403
6272
)
6373

nightwatch/bot/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

nightwatch/bot/client.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

nightwatch/bot/types.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

nightwatch/desktop/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "nightwatch-desktop",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"tauri": "tauri"
8+
},
9+
"devDependencies": {
10+
"@tauri-apps/cli": ">=2.0.0-beta.0"
11+
}
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Generated by Cargo
22
# will have compiled files and executables
33
/target/
4+
5+
# Generated by Tauri
6+
# will have schema files for capabilities auto-completion
7+
/gen/schemas

0 commit comments

Comments
 (0)