Beispiel #1
0
    def __init__(self):
        super().__init__()

        self.db = core.get_database()
        self.connected = self.db.test()

        if not self.connected:
            log.error('not connected')
            exit()
            return

        core.init_database(defs)
Beispiel #2
0
import datetime, jwt
from ..libs import user_lib, sql_lib, secure_lib

from ..models.database.users_definitions import User, UserSession

from ..models.main import AlphaException

from core import core

from flask import request

API = core.api
DB = core.get_database("users")

LOG = core.get_logger("users")
LOGIN_MODE = core.api.conf.get("auth/mode")
if LOGIN_MODE == "ldap":
    import ldap
    LDAP_SERVER = API.conf.get("auth/ldap/server")
    BASE_DN = API.conf.get("auth/ldap/baseDN")


# Serve for registration
def try_register_user(mail,
                      username,
                      password,
                      password_confirmation,
                      validation=True):
    userByMail = user_lib.get_user_data_by_mail(mail)
    userByUsername = user_lib.get_user_data_by_username(username)
Beispiel #3
0
from .models import (
    AlphaTable,
    AlphaTableId,
    AlphaColumn,
    AlphaFloat,
    AlphaInteger,
    AlphaTableIdUpdateDate,
    AlphaTableUpdateDate,
)

import datetime, inspect, ast

from core import core

db = core.get_database()
ma = core.ma

BIND = "users"


class UserSession(db.Model, AlphaTable):
    __bind_key__ = BIND
    __tablename__ = "user_session"

    user_id = AlphaColumn(Integer, primary_key=True)
    token = AlphaColumn(String(255))
    ip = AlphaColumn(String(50))
    expire = AlphaColumn(DateTime)

Beispiel #4
0
from core import core

api = core.api
db = core.get_database('logs')


def clear_logs():
    query = "TRUNCATE logs"
    return db.execute(query)


def get_logs(start_date=None, end_date=None, useLimit=False, pageForLimit=1):
    total = 0
    logs = []
    limit = 20
    start = (pageForLimit - 1) * limit

    query = "SELECT COUNT(*) AS count FROM logs"
    parameters = []
    if start_date is not None and end_date is not None:
        query += " AND CAST(date AS DATE) between %s and %s"
        parameters.append(start_date)
        parameters.append(end_date)
    query += " ORDER BY date DESC"

    rows = db.get(query, parameters)
    for row in rows:
        total = row[0]

    query = "SELECT type, origin, message, stack, date FROM logs"
    parameters = []