using current user in some placesi
This commit is contained in:
23
.idea/workspace.xml
generated
23
.idea/workspace.xml
generated
@@ -5,28 +5,16 @@
|
|||||||
<change beforePath="$PROJECT_DIR$/../.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/../.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../activate_this.py" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/../activate_this.py" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$" beforeDir="false" afterPath="$PROJECT_DIR$" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$" beforeDir="false" afterPath="$PROJECT_DIR$" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/backend.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/backend.iml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/__init__.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/api/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/api/__init__.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/api/auth_api.py" beforeDir="false" afterPath="$PROJECT_DIR$/api/auth_api.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/api/control_api.py" beforeDir="false" afterPath="$PROJECT_DIR$/api/control_api.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/api/user_api.py" beforeDir="false" afterPath="$PROJECT_DIR$/api/user_api.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/api/user_api.py" beforeDir="false" afterPath="$PROJECT_DIR$/api/user_api.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/auth/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/auth/__init__.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/auth/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/auth/__init__.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/auth/basic_auth.py" beforeDir="false" afterPath="$PROJECT_DIR$/auth/basic_auth.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/auth/config.py" beforeDir="false" afterPath="$PROJECT_DIR$/auth/config.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/auth/templates/login.html" beforeDir="false" afterPath="$PROJECT_DIR$/auth/templates/login.html" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/config.py" beforeDir="false" afterPath="$PROJECT_DIR$/config.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/models/recorder_model.py" beforeDir="false" afterPath="$PROJECT_DIR$/models/recorder_model.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/models/user_model.py" beforeDir="false" afterPath="$PROJECT_DIR$/models/user_model.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/../frontend" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend/src/api/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/index.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/../frontend/src/App.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/App.vue" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend/src/api/userRepository.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/userRepository.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/../frontend/src/components/Login.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/components/Login.vue" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend/src/components/Profile.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/components/Profile.vue" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/../frontend/src/components/Profile.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/components/Profile.vue" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend/src/main.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/main.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/../frontend/src/main.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/main.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../frontend/src/plugins/i18n.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/plugins/i18n.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/../frontend/src/plugins/i18n.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/plugins/i18n.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/../frontend/src/views/NotFound.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/views/NotFound.vue" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@@ -232,7 +220,8 @@
|
|||||||
<workItem from="1557483399929" duration="284000" />
|
<workItem from="1557483399929" duration="284000" />
|
||||||
<workItem from="1557483805341" duration="173000" />
|
<workItem from="1557483805341" duration="173000" />
|
||||||
<workItem from="1565770023268" duration="8793000" />
|
<workItem from="1565770023268" duration="8793000" />
|
||||||
<workItem from="1565778873035" duration="9376000" />
|
<workItem from="1565778873035" duration="11976000" />
|
||||||
|
<workItem from="1565851033796" duration="1206000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@@ -263,6 +252,6 @@
|
|||||||
<SUITE FILE_PATH="coverage/backend$extron_smp.coverage" NAME="extron_smp Coverage Results" MODIFIED="1565782117031" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/recorder_adapters" />
|
<SUITE FILE_PATH="coverage/backend$extron_smp.coverage" NAME="extron_smp Coverage Results" MODIFIED="1565782117031" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/recorder_adapters" />
|
||||||
<SUITE FILE_PATH="coverage/backend$main.coverage" NAME="main Coverage Results" MODIFIED="1557306314589" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/../../oc_media_portal/backend" />
|
<SUITE FILE_PATH="coverage/backend$main.coverage" NAME="main Coverage Results" MODIFIED="1557306314589" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/../../oc_media_portal/backend" />
|
||||||
<SUITE FILE_PATH="coverage/backend$backend.coverage" NAME="backend Coverage Results" MODIFIED="1556810339611" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
<SUITE FILE_PATH="coverage/backend$backend.coverage" NAME="backend Coverage Results" MODIFIED="1556810339611" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
||||||
<SUITE FILE_PATH="coverage/backend$__main__.coverage" NAME="__main__ Coverage Results" MODIFIED="1565793060617" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
<SUITE FILE_PATH="coverage/backend$__main__.coverage" NAME="__main__ Coverage Results" MODIFIED="1565851651603" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -8,15 +8,12 @@ Login through API does not start a new session, but instead returns JWT.
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
import flask
|
|
||||||
import jwt
|
from flask_jwt_extended import get_jwt_identity, jwt_required, current_user
|
||||||
from flask import request, jsonify, current_app, url_for
|
|
||||||
from flask_jwt_extended import get_jwt_identity, jwt_optional, jwt_required
|
|
||||||
from flask_restplus import Resource, fields, inputs
|
from flask_restplus import Resource, fields, inputs
|
||||||
|
|
||||||
from backend import db, app, jwt_auth
|
from backend import db, app, jwt_auth
|
||||||
from backend.api import api_bp, api_user
|
from backend.api import api_user
|
||||||
from backend.auth import oidc_auth
|
|
||||||
from backend.models.user_model import User, Group
|
from backend.models.user_model import User, Group
|
||||||
|
|
||||||
user_model = api_user.model('User', {
|
user_model = api_user.model('User', {
|
||||||
@@ -36,6 +33,7 @@ user_update_parser.add_argument('nickname', type=str, required=False, store_miss
|
|||||||
user_update_parser.add_argument('first_name', type=str, required=False, store_missing=False)
|
user_update_parser.add_argument('first_name', type=str, required=False, store_missing=False)
|
||||||
user_update_parser.add_argument('last_name', type=str, required=False, store_missing=False)
|
user_update_parser.add_argument('last_name', type=str, required=False, store_missing=False)
|
||||||
|
|
||||||
|
|
||||||
@api_user.route('/profile')
|
@api_user.route('/profile')
|
||||||
class Profile(Resource):
|
class Profile(Resource):
|
||||||
@jwt_required
|
@jwt_required
|
||||||
@@ -47,19 +45,17 @@ class Profile(Resource):
|
|||||||
return User.get_by_identifier(current_user_id)
|
return User.get_by_identifier(current_user_id)
|
||||||
|
|
||||||
@jwt_required
|
@jwt_required
|
||||||
|
@api_user.expect(user_update_parser)
|
||||||
def put(self):
|
def put(self):
|
||||||
current_user_id = get_jwt_identity()
|
|
||||||
print(api_user.payload)
|
|
||||||
app.logger.info(current_user_id)
|
|
||||||
args = user_update_parser.parse_args()
|
args = user_update_parser.parse_args()
|
||||||
args['last_time_modified'] = datetime.utcnow()
|
args['last_time_modified'] = datetime.utcnow()
|
||||||
pprint(args)
|
pprint(args)
|
||||||
|
print(current_user)
|
||||||
num_rows_matched = User.query.filter_by(id=current_user_id).update(args)
|
num_rows_matched = User.query.filter_by(id=current_user.id).update(args)
|
||||||
print(num_rows_matched)
|
print(num_rows_matched)
|
||||||
|
|
||||||
if num_rows_matched < 1:
|
if num_rows_matched < 1:
|
||||||
api_user.abort(404)
|
api_user.abort("Nothing has been updated!")
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return "ok"
|
return "ok"
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ def user_identity_loader(user):
|
|||||||
|
|
||||||
@jwt_extended.user_loader_callback_loader
|
@jwt_extended.user_loader_callback_loader
|
||||||
def user_loader_callback(identity):
|
def user_loader_callback(identity):
|
||||||
user = User.get_by_identifier(identity)
|
print("### user_loader_callback_loader")
|
||||||
return user
|
return User.get_by_identifier(identity)
|
||||||
|
|
||||||
|
|
||||||
@jwt_extended.token_in_blacklist_loader
|
@jwt_extended.token_in_blacklist_loader
|
||||||
|
|||||||
Reference in New Issue
Block a user