fix: get application details failed (#481)

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
不羁
2019-06-20 16:23:24 +08:00
committed by GitHub
parent 836c011eeb
commit 4283814a68
9 changed files with 94 additions and 13 deletions

View File

@@ -55,7 +55,7 @@ const (
KindTokenReview = "TokenReview"
)
func LoginHandler(req *restful.Request, resp *restful.Response) {
func Login(req *restful.Request, resp *restful.Response) {
var loginRequest LoginRequest
err := req.ReadEntity(&loginRequest)
@@ -70,6 +70,10 @@ func LoginHandler(req *restful.Request, resp *restful.Response) {
token, err := iam.Login(loginRequest.Username, loginRequest.Password, ip)
if err != nil {
if serviceError, ok := err.(restful.ServiceError); ok {
resp.WriteHeaderAndEntity(serviceError.Code, errors.New(serviceError.Message))
return
}
resp.WriteHeaderAndEntity(http.StatusUnauthorized, errors.Wrap(err))
return
}