add
This commit is contained in:
@@ -28,7 +28,7 @@ func (h *Handler) Register(w http.ResponseWriter, r *http.Request) {
|
||||
httpx.BadRequest(w, "invalid json")
|
||||
return
|
||||
}
|
||||
userID, err := h.S.Register(req.Account, req.Password)
|
||||
userID, token, err := h.S.Register(req.Account, req.Password)
|
||||
if err != nil {
|
||||
switch err {
|
||||
case service.ErrInvalidInput:
|
||||
@@ -40,7 +40,7 @@ func (h *Handler) Register(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
return
|
||||
}
|
||||
httpx.Created(w, map[string]string{"user_id": userID})
|
||||
httpx.Created(w, map[string]string{"user_id": userID, "token": token})
|
||||
}
|
||||
|
||||
func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -53,7 +53,7 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
|
||||
httpx.BadRequest(w, "invalid json")
|
||||
return
|
||||
}
|
||||
userID, err := h.S.Login(req.Account, req.Password)
|
||||
userID, token, err := h.S.Login(req.Account, req.Password)
|
||||
if err != nil {
|
||||
switch err {
|
||||
case service.ErrInvalidInput:
|
||||
@@ -65,7 +65,7 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
return
|
||||
}
|
||||
httpx.OK(w, map[string]string{"user_id": userID})
|
||||
httpx.OK(w, map[string]string{"user_id": userID, "token": token})
|
||||
}
|
||||
|
||||
func (h *Handler) Healthz(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user