Skip to content

Commit 6d0ccaf

Browse files
authored
Merge pull request #5106 from 2403905/issue-11004-2
Fix the OCM invite response message on bad request
2 parents 35ccd7c + 6ed7bb6 commit 6d0ccaf

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Bugfix: Fix the OCM invite response message on bad request
2+
3+
Fix the OCM invite response message on bad request.
4+
5+
https://github.com/cs3org/reva/pull/5106
6+
https://github.com/owncloud/ocis/issues/11004

internal/http/services/sciencemesh/token.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ func (h *tokenHandler) AcceptInvite(w http.ResponseWriter, r *http.Request) {
223223
reqres.WriteError(w, r, reqres.APIErrorServerError, "error sending a grpc forward invite request", err)
224224
return
225225
}
226-
if forwardInviteResponse.Status.Code != rpc.Code_CODE_OK {
227-
switch forwardInviteResponse.Status.Code {
226+
if forwardInviteResponse.GetStatus().GetCode() != rpc.Code_CODE_OK {
227+
switch forwardInviteResponse.GetStatus().GetCode() {
228228
case rpc.Code_CODE_NOT_FOUND:
229229
reqres.WriteError(w, r, reqres.APIErrorNotFound, "token not found", nil)
230230
return
231231
case rpc.Code_CODE_INVALID_ARGUMENT:
232-
reqres.WriteError(w, r, reqres.APIErrorInvalidParameter, "token has expired", nil)
232+
reqres.WriteError(w, r, reqres.APIErrorInvalidParameter, forwardInviteResponse.GetStatus().GetMessage(), nil)
233233
return
234234
case rpc.Code_CODE_ALREADY_EXISTS:
235235
reqres.WriteError(w, r, reqres.APIErrorAlreadyExist, "user already known", nil)
@@ -238,7 +238,8 @@ func (h *tokenHandler) AcceptInvite(w http.ResponseWriter, r *http.Request) {
238238
reqres.WriteError(w, r, reqres.APIErrorUnauthenticated, "remote service not trusted", nil)
239239
return
240240
default:
241-
reqres.WriteError(w, r, reqres.APIErrorServerError, "unexpected error: "+forwardInviteResponse.Status.Message, errors.New(forwardInviteResponse.Status.Message))
241+
log.Err(errors.New(forwardInviteResponse.GetStatus().GetMessage())).Msg("unexpected error")
242+
reqres.WriteError(w, r, reqres.APIErrorServerError, "unexpected error", nil)
242243
return
243244
}
244245
}

0 commit comments

Comments
 (0)