Skip to content

Commit

Permalink
rename login method - close #19
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Polyakov committed Jun 19, 2024
1 parent bbcb04b commit 37f6248
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ servers:
- url: 'http://localhost:4102'
description: Local server
paths:
/api/login:
/api/v1/auth/signin:
post:
tags:
- Sessions
Expand Down Expand Up @@ -60,7 +60,7 @@ paths:
'500':
description: Internal Server Error
parameters: []
/api/logout:
/api/v1/auth/signout:
post:
tags:
- Sessions
Expand Down
8 changes: 4 additions & 4 deletions internal/app/handlers/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func (siw *ServerInterfaceWrapper) UpdateGame(w http.ResponseWriter, r *http.Req
siw.handlers.UpdateGame(w, r, id)
}

func (siw *ServerInterfaceWrapper) PostApiLogin(w http.ResponseWriter, r *http.Request) {
siw.handlers.PostApiLogin(w, r)
func (siw *ServerInterfaceWrapper) PostApiV1AuthSignin(w http.ResponseWriter, r *http.Request) {
siw.handlers.PostApiV1AuthSignin(w, r)
}

func (siw *ServerInterfaceWrapper) PostApiLogout(w http.ResponseWriter, r *http.Request) {
siw.handlers.PostApiLogout(w, r)
func (siw *ServerInterfaceWrapper) PostApiV1AuthSignout(w http.ResponseWriter, r *http.Request) {
siw.handlers.PostApiV1AuthSignout(w, r)
}

func (siw *ServerInterfaceWrapper) ListResults(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 3 additions & 3 deletions internal/app/handlers/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
api_helpers "ctf01d/internal/app/utils"
)

func (h *Handlers) PostApiLogin(w http.ResponseWriter, r *http.Request) {
var req server.PostApiLoginJSONBody
func (h *Handlers) PostApiV1AuthSignin(w http.ResponseWriter, r *http.Request) {
var req server.PostApiV1AuthSigninJSONBody
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
slog.Warn(err.Error(), "handler", "LoginSessionHandler")
http.Error(w, "Invalid request body", http.StatusBadRequest)
Expand Down Expand Up @@ -44,7 +44,7 @@ func (h *Handlers) PostApiLogin(w http.ResponseWriter, r *http.Request) {
api_helpers.RespondWithJSON(w, http.StatusOK, map[string]string{"data": "User logged in"})
}

func (h *Handlers) PostApiLogout(w http.ResponseWriter, r *http.Request) {
func (h *Handlers) PostApiV1AuthSignout(w http.ResponseWriter, r *http.Request) {
cookie, err := r.Cookie("session_id")
if err != nil {
slog.Warn(err.Error(), "handler", "LogoutSessionHandler")
Expand Down
126 changes: 63 additions & 63 deletions internal/app/server/server.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 37f6248

Please sign in to comment.