def login(): username = request.json.get('username') or http_error( 500, 'USERNAME is required!') password = request.json.get('password') or http_error( 500, 'PASSWORD is required!') user = User.query.filter_by(username=username).first() or http_error( 401, 'Unauthorized! USER not found!') last_login(username) if user.check_password(password): return jsonify({ 'user': user_schema.dump(user), "token": token(user.id) }) else: return http_error(401, 'Unauthorized! PASSWORD not found!')
def get(): systemconfiguration = SystemConfiguration.query.all() or http_error(204) return jsonify({"data": systemconfiguration}), 200
def find(systemconfiguration_id): systemconfiguration = SystemConfiguration.query.filter_by( id=systemconfiguration_id).first() or http_error(204) return jsonify({"message": systemconfiguration}), 200
def get(): user = User.query.all() or http_error(204) return jsonify({"data": user}), 200
def find(user_id): user = User.query.filter_by(id=user_id).first() or http_error(204) return jsonify({"message": user}), 200
def user_exists(): username = request.json.get('username') or http_error( 500, 'USERNAME is required!') user = User.query.filter_by(username=username).first() or http_error( 204, 'USERNAME is required!') return jsonify({"username": user.username}), 200
def get(): country = Country.query.all() or http_error(204) return jsonify({"data": country}), 200
def find(file_id): file = File.query.filter_by(id=file_id).first() or http_error(204) return jsonify({"message": file}), 200
def find(site_id): site = Site.query.filter_by(id=site_id).first() or http_error(204) return jsonify({"message": site}), 200
def get(): mailaccount = MailAccount.query.all() or http_error(204) return jsonify({"data": mailaccount}), 200
def find(mailaccount_id): mailaccount = MailAccount.query.filter_by( id=mailaccount_id).first() or http_error(204) return jsonify({"message": mailaccount}), 200
def get(): maildomain = MailDomain.query.all() or http_error(204) return jsonify({"data": maildomain}), 200
def find(maildomain_id): maildomain = MailDomain.query.filter_by( id=maildomain_id).first() or http_error(204) return jsonify({"message": maildomain}), 200
def get(): template = Template.query.all() or http_error(204) return jsonify({"data": template}), 200
def find(template_id): template = Template.query.filter_by(id=template_id).first() or http_error(204) return jsonify({"message": template}), 200
def find(customer_id): customer = Customer.query.filter_by( id=customer_id).first() or http_error(204) return jsonify({"message": customer}), 200
def get(): customer = Customer.query.all() or http_error(204) return jsonify({"data": customer}), 200
def get(): site = Site.query.all() or http_error(204) return jsonify({"data": site}), 200
def get(): file = File.query.all() or http_error(204) return jsonify({"data": file}), 200
def find(country_id): country = Country.query.filter_by(id=country_id).first() or http_error(204) return jsonify({"message": country}), 200