refactor: change login to respond with the jwt token in the body
This commit is contained in:
parent
550398c701
commit
91d58ee87f
|
@ -108,8 +108,9 @@ func (a AccountAPI) login(jc jape.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
jc.ResponseWriter.Header().Set("Authorization", "Bearer "+jwt)
|
||||
jc.ResponseWriter.WriteHeader(http.StatusOK)
|
||||
jc.Encode(&LoginResponse{
|
||||
Token: jwt,
|
||||
})
|
||||
}
|
||||
|
||||
func (a AccountAPI) register(jc jape.Context) {
|
||||
|
|
|
@ -5,6 +5,10 @@ type LoginRequest struct {
|
|||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type RegisterRequest struct {
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
|
|
|
@ -16,11 +16,10 @@ paths:
|
|||
responses:
|
||||
'200':
|
||||
description: Successfully logged in
|
||||
headers:
|
||||
Authorization:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
description: Bearer token for the session
|
||||
$ref: '#/components/schemas/LoginResponse'
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/api/auth/register:
|
||||
|
@ -132,6 +131,11 @@ components:
|
|||
type: string
|
||||
password:
|
||||
type: string
|
||||
LoginResponse:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
RegisterRequest:
|
||||
type: object
|
||||
required:
|
||||
|
|
Loading…
Reference in New Issue