mirror of
https://github.com/wahyd4/loginsrv.git
synced 2026-08-09 04:46:29 +10:00
Adjust behavior on empty username and token refresh
This commit is contained in:
@@ -172,6 +172,11 @@ func (h *Handler) handleLogin(w http.ResponseWriter, r *http.Request) {
|
||||
h.handleRefresh(w, r, userInfo)
|
||||
return
|
||||
}
|
||||
if username == "" {
|
||||
h.respondAuthFailure(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
h.respondBadRequest(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ func TestHandler_Refresh_Expired(t *testing.T) {
|
||||
|
||||
// refreshSuccess
|
||||
recorder := call(req("POST", "/context/login", "", AcceptHTML, cookieStr))
|
||||
Equal(t, 400, recorder.Code)
|
||||
Equal(t, 403, recorder.Code)
|
||||
|
||||
// verify the token from the cookie
|
||||
setCookieList := readSetCookies(recorder.Header())
|
||||
@@ -295,7 +295,7 @@ func TestHandler_Refresh_Invalid_Token(t *testing.T) {
|
||||
|
||||
// refreshSuccess
|
||||
recorder := call(req("POST", "/context/login", "", AcceptHTML, cookieStr))
|
||||
Equal(t, 400, recorder.Code)
|
||||
Equal(t, 403, recorder.Code)
|
||||
|
||||
// verify the token from the cookie
|
||||
setCookieList := readSetCookies(recorder.Header())
|
||||
|
||||
Reference in New Issue
Block a user