Add new config "enable_login".

This commit is contained in:
voussoir 2017-07-20 23:25:23 -07:00
parent 797b3376a7
commit 4fc203634c
3 changed files with 5 additions and 0 deletions

View file

@ -156,6 +156,7 @@ DEFAULT_CONFIGURATION = {
'cache_size_user': 200, 'cache_size_user': 200,
'enable_album_edit': True, 'enable_album_edit': True,
'enable_login': True,
'enable_new_album': True, 'enable_new_album': True,
'enable_new_bookmark': True, 'enable_new_bookmark': True,
'enable_new_photo': True, 'enable_new_photo': True,

View file

@ -1006,6 +1006,7 @@ class PDBUserMixin:
author_id = None author_id = None
return author_id return author_id
@decorators.required_feature('enable_login')
def login(self, user_id, password): def login(self, user_id, password):
cur = self.sql.cursor() cur = self.sql.cursor()
cur.execute('SELECT * FROM users WHERE id == ?', [user_id]) cur.execute('SELECT * FROM users WHERE id == ?', [user_id])

View file

@ -648,6 +648,9 @@ def post_login():
e = etiquette.exceptions.WrongLogin() e = etiquette.exceptions.WrongLogin()
response = etiquette.jsonify.exception(e) response = etiquette.jsonify.exception(e)
return jsonify.make_json_response(response, status=422) return jsonify.make_json_response(response, status=422)
except etiquette.exceptions.FeatureDisabled as e:
response = etiquette.jsonify.exception(e)
return jsonify.make_json_response(response, status=400)
session = sessions.Session(request, user) session = sessions.Session(request, user)
session_manager.add(session) session_manager.add(session)
return jsonify.make_json_response({}) return jsonify.make_json_response({})