Spaces:
Sleeping
Sleeping
|
Download auth_module/README.md from moshabann/echo-tutor: direct link, hf CLI and curl.
- Browser
- Download file 3.37 kB
-
https://huggingface.co/spaces/moshabann/echo-tutor/resolve/main/auth_module/README.md
- Command line
-
hf download hf://spaces/moshabann/echo-tutor/auth_module/README.md
-
curl -L -o README.md https://huggingface.co/spaces/moshabann/echo-tutor/resolve/main/auth_module/README.md
3.37 kB
๐ RobovAI Auth Module โ Standalone Package
ูุธุงู ุชุณุฌูู + ุชุณุฌูู ุฏุฎูู + ุชูุนูู ุนุจุฑ Telegram OTP โ ุฌุงูุฒ ููููู ูุฃู ุชุทุจูู FastAPI. ูุฏุนู ุงูุจูุช ุงูู ุฑูุฒู (@robovainova_bot) ุนูู ุณูุฑูุฑ ู ุฎุชูู ุนุจุฑ Nova API.
ุงูู ููุงุช
| ู ูู | ุงููุธููุฉ |
|---|---|
security.py |
JWT tokens, password hashing, password validation |
database.py |
SQLite: users, sessions, OTP, CRUD |
auth_routes.py |
FastAPI routes: signup, login, logout, OTP, verify, me |
nova_client.py |
HTTP client โ pushes OTP to Nova for Telegram bot delivery |
telegram_verify.py |
(ุงุฎุชูุงุฑู) Telegram bot ู ุณุชูู ููุชูุนูู |
config.py |
Settings / environment variables |
models.py |
Pydantic request/response models |
ุงูุงุณุชุฎุฏุงู ุงูุณุฑูุน (ุณูุฑูุฑ ู ุฎุชูู + ุจูุช ู ุฑูุฒู)
# main.py
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from auth_module.auth_routes import auth_router, get_current_user
app = FastAPI(title="My App")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Auth routes: /auth/signup, /auth/login, /auth/logout, /auth/me, etc.
app.include_router(auth_router, prefix="/auth", tags=["Auth"])
# Your app routes...
@app.get("/")
def root():
return {"app": "running"}
ุงูููู
1. ุงูู
ุณุชุฎุฏู
ูุนู
ู signup โ POST /auth/signup
2. auth_module ููููุฏ OTP โ ูุฎุฒูู ู
ุญููุงู + ูุจุนุชู ูู Nova API
3. ุงูู
ุณุชุฎุฏู
ูุฑูุญ @robovainova_bot โ /verify โ ูุฏุฎู ุฅูู
ููู
4. ุงูุจูุช ููุงูู ุงูู OTP โ ูุจุนุชูููู ุนุจุฑ ุชููุฌุฑุงู
5. ุงูู
ุณุชุฎุฏู
ูุฏุฎู ุงูู OTP ูู ุงูู
ููุน โ POST /auth/verify-otp
6. ุงูุญุณุงุจ ูุชูุนูู โ
ุงูู ุชุทูุจุงุช
fastapi>=0.100.0
uvicorn[standard]
pyjwt>=2.8.0
passlib[bcrypt]>=1.7.4
pydantic-settings>=2.0.0
python-dotenv>=1.0.0
python-multipart>=0.0.6
httpx>=0.25.0
ุงูุจูุฆุฉ (.env)
# ู
ุทููุจ โ JWT Secret
JWT_SECRET_KEY=your-secret-key-min-32-chars
# ู
ุทููุจ โ ุฑุจุท ุจุงูุจูุช ุงูู
ุฑูุฒู
NOVA_API_URL=https://robovai-nova.onrender.com
NOVA_API_KEY=nova_ext_9f3k7Lm2Xp8qR4vW6yB1cD5eH0jN
APP_ID=my-new-app
# ุงุฎุชูุงุฑู
DATABASE_PATH=users.db
ู ูุงุญุธุฉ: ุงูู
NOVA_API_KEYูุงุฒู ูููู ููุณ ุงูููู ุฉ ุงูู ูุฌูุฏุฉ ููEXTERNAL_API_KEYุนูู ุณูุฑูุฑ Nova.
Signup Page JavaScript Example
// After successful signup, poll for verification
async function pollVerification(email) {
const interval = setInterval(async () => {
const res = await fetch(`/auth/check-verified?email=${email}`);
const data = await res.json();
if (data.verified) {
clearInterval(interval);
alert("โ
ุชู
ุชูุนูู ุญุณุงุจู!");
window.location.href = "/login";
}
}, 3000); // Poll every 3 seconds
}