def auth_session_post(): username = flask.request.json['username'] password = flask.request.json['password'] remote_addr = utils.get_remote_addr() admin = auth.check_auth(username, password, remote_addr) if not admin: return utils.jsonify({ 'error': AUTH_INVALID, 'error_msg': AUTH_INVALID_MSG, }, 401) flask.session['admin_id'] = str(admin.id) flask.session['timestamp'] = int(time.time()) if not settings.conf.ssl: flask.session['source'] = remote_addr return utils.jsonify({ 'authenticated': True, 'default': admin.default, })