Some fixes
This commit is contained in:
parent
dc33b5567a
commit
09a809192a
2 changed files with 9 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ import os
|
||||||
# here should go `from .utils import get_current_user`, but it will cause
|
# here should go `from .utils import get_current_user`, but it will cause
|
||||||
# import errors. It's instead imported at function level.
|
# import errors. It's instead imported at function level.
|
||||||
|
|
||||||
database = SqliteDatabase(os.path.join(os.getcwd(), 'coriplus.sqlite'))
|
database = SqliteDatabase(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'coriplus.sqlite'))
|
||||||
|
|
||||||
class BaseModel(Model):
|
class BaseModel(Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
||||||
11
app/utils.py
11
app/utils.py
|
|
@ -101,9 +101,14 @@ except OSError:
|
||||||
# get the user from the session
|
# get the user from the session
|
||||||
# changed in 0.5 to comply with flask_login
|
# changed in 0.5 to comply with flask_login
|
||||||
def get_current_user():
|
def get_current_user():
|
||||||
user_id = session.get('user_id')
|
# new in 0.7; need a different method to get current user id
|
||||||
if user_id:
|
if request.path.startswith('/api/'):
|
||||||
return User[user_id]
|
# assume token validation is already done
|
||||||
|
return User[request.args['access_token'].split(':')[0]]
|
||||||
|
else:
|
||||||
|
user_id = session.get('user_id')
|
||||||
|
if user_id:
|
||||||
|
return User[user_id]
|
||||||
|
|
||||||
def push_notification(type, target, **kwargs):
|
def push_notification(type, target, **kwargs):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue