Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ログアウト機能実装 #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SAASUS_SAAS_ID=
SAASUS_API_KEY=
SAASUS_SECRET_KEY=
DATABASE_URL=postgresql://user:password@localhost:5432/postgres
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
10 changes: 9 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import uvicorn
from typing import Union, Optional
from fastapi import FastAPI, Request, Depends, HTTPException, Header, Query, Cookie
from fastapi import FastAPI, Request, Response, Depends, HTTPException, Query
from pydantic import BaseModel
from starlette.middleware.cors import CORSMiddleware

Expand Down Expand Up @@ -472,5 +472,13 @@ def refresh(request: Request):
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))

# ログアウト
@app.post("/logout")
def logout(response: Response):
# クライアントのクッキーを削除する
response.delete_cookie("SaaSusRefreshToken")

return {"message": "Logged out successfully"}

if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=80)