diff --git a/oauth2_provider/app/views/applications.py b/oauth2_provider/app/views/applications.py index 15c710df20a1afef2dd0d43530bb61c9bb01dffd..8aeeefa0dd06bd5f604b62d53dba1bee8d8e4db9 100644 --- a/oauth2_provider/app/views/applications.py +++ b/oauth2_provider/app/views/applications.py @@ -10,10 +10,10 @@ # PURPOSE. # See the Mulan PSL v2 for more details. # ******************************************************************************/ -from flask import request +from flask import request, g from vulcanus.log.log import LOGGER from vulcanus.restful.resp import state -from oauth2_provider.app.views import validate_request +from oauth2_provider.app.views import validate_request, login_require from vulcanus.restful.response import BaseResponse from oauth2_provider.app.core.applications import ApplicationProxy from vulcanus.restful.resp.state import SUCCEED, PERMESSION_ERROR @@ -25,9 +25,9 @@ class ApplicationsView(BaseResponse): Application management views """ + @login_require def get(self): - username = "123456" - status_code, applications = ApplicationProxy().get_all_applications(username) + status_code, applications = ApplicationProxy().get_all_applications(g.username) ret_data = { "number": len(applications), "applications": applications @@ -40,10 +40,10 @@ class ApplicationsRegisteView(BaseResponse): Application registration views """ + @login_require @validate_request(schema=Oauth2ClientSchema) def post(self, request_body, **params): - username = "123456" - request_body['username'] = username + request_body['username'] = g.username status_code, application = ApplicationProxy().create_application(request_body) return self.response(code=status_code, data=application) @@ -54,19 +54,18 @@ class ApplicationsDetailView(BaseResponse): """ def get(self, client_id): - username = "123456" status_code, application = ApplicationProxy().get_one_application( client_id=client_id, - username=username + username=g.username ) return self.response(code=status_code, data=application) + @login_require @validate_request(schema=UpdateOauth2ClientSchema) def put(self, client_id, request_body, **params): - manage_user = "123456" status_code = ApplicationProxy().update_one_application( - username=manage_user, + username=g.username, client_id=client_id, data=request_body ) @@ -75,16 +74,15 @@ class ApplicationsDetailView(BaseResponse): else: status_code, application = ApplicationProxy().get_one_application( client_id=client_id, - username=manage_user + username=g.username ) return self.response(code=status_code, data=application) def delete(self, client_id): - username="123456" status_code = ApplicationProxy().delete_one_application( client_id=client_id, - username=username + username=g.username ) return self.response(code=status_code)