Beispiel #1
0
def create_account():
    if request.method == "POST":
        username = request.form["username"]
        password = request.form["password"]
        result = security.create_account(username, password)
        if not result:
            flash("Käyttäjänimi on jo käytössä. Yritä uudelleen.")
            return render_template("create_account.html")
        security.login(username, password)
        return redirect("/")
    else:
        return render_template("create_account.html")
Beispiel #2
0
def exp_login(db, login, password):
    # TODO: legacy indirection through 'security', should use directly
    # the res.users model
    res = security.login(db, login, password)
    msg = res and 'successful login' or 'bad login or password'
    _logger.info("%s from '%s' using database '%s'", msg, login, db.lower())
    return res or False
Beispiel #3
0
    def dispatch(self, method, auth, params):
        logger = netsvc.Logger()
        if method in [ 'ir_set','ir_del', 'ir_get' ]:
            return self.common_dispatch(method,auth,params)
        if method == 'login':
            # At this old dispatcher, we do NOT update the auth proxy
            res = security.login(params[0], params[1], params[2])
            msg = res and 'successful login' or 'bad login or password'
            # TODO log the client ip address..
            logger.notifyChannel("web-service", netsvc.LOG_INFO, "%s from '%s' using database '%s'" % (msg, params[1], params[0].lower()))
            return res or False
        elif method == 'logout':
            if auth:
                auth.logout(params[1])
            logger.notifyChannel("web-service", netsvc.LOG_INFO,'Logout %s from database %s'%(login,db))
            return True
        elif method in ['about', 'timezone_get', 'get_server_environment',
                        'login_message','get_stats', 'check_connectivity',
                        'list_http_services']:
            pass
        elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel', 'get_os_time', 'get_sqlcount']:
            passwd = params[0]
            params = params[1:]
            security.check_super(passwd)
        else:
            raise Exception("Method not found: %s" % method)

        fn = getattr(self, 'exp_'+method)
        return fn(*params)
Beispiel #4
0
 def exp_login(self, db, login, password):
     # TODO: legacy indirection through 'security', should use directly
     # the res.users model
     res = security.login(db, login, password)
     msg = res and 'successful login' or 'bad login or password'
     _logger.info("%s from '%s' using database '%s'", msg, login, db.lower())
     return res or False
Beispiel #5
0
 def dispatch(self, method, auth, params):
     logger = netsvc.Logger()
     if method in [ 'ir_set','ir_del', 'ir_get' ]:
         return self.common_dispatch(method,auth,params)
     if method == 'login':
         # At this old dispatcher, we do NOT update the auth proxy
         res = security.login(params[0], params[1], params[2])
         msg = res and 'successful login' or 'bad login or password'
         # TODO log the client ip address..
         logger.notifyChannel("web-service", netsvc.LOG_INFO, "%s from '%s' using database '%s'" % (msg, params[1], params[0].lower()))
         return res or False
     elif method == 'logout':
         if auth:
             auth.logout(params[1])
         logger.notifyChannel("web-service", netsvc.LOG_INFO,'Logout %s from database %s'%(login,db))
         return True
     elif method in ['about', 'timezone_get', 'get_server_environment',
                     'login_message','get_stats', 'check_connectivity']:
         pass
     elif method in ['get_available_updates', 'get_migration_scripts', 'set_loglevel']:
         passwd = params[0]
         params = params[1:]
         security.check_super(passwd)
     else:
         raise Exception("Method not found: %s" % method)
     
     fn = getattr(self, 'exp_'+method)
     return fn(*params)
Beispiel #6
0
 def authenticate(self, db, user, passwd, client_address):
     try:
         uid = security.login(db, user, passwd)
         if uid is False:
             return False
         return user, passwd, db, uid
     except Exception, e:
         _logger.debug("Fail auth: %s" % e)
         return False
 def authenticate(self, db, user, passwd, client_address):
     try:
         uid = security.login(db,user,passwd)
         if uid is False:
             return False
         return (user, passwd, db, uid)
     except Exception,e:
         logging.getLogger("auth").debug("Fail auth: %s" % e )
         return False
Beispiel #8
0
 def authenticate(self, db, user, passwd, client_address):
     try:
         uid = security.login(db,user,passwd)
         if uid is False:
             return False
         return user, passwd, db, uid
     except Exception,e:
         _logger.debug("Fail auth: %s" % e )
         return False
Beispiel #9
0
 def authenticate(self, db, user, passwd, client_address):
     try:
         uid = security.login(db, user, passwd)
         if uid is False:
             return False
         return (user, passwd, db, uid)
     except Exception, e:
         logging.getLogger("auth").debug("Fail auth: %s" % e)
         return False
Beispiel #10
0
def login():
    username = request.form["username"]
    password = request.form["password"]
    result = security.login(username, password)
    if result == "Success":
        return redirect(request.referrer)
    else:
        flash("Invalid credentials. Try again.")
        return redirect(request.referrer)
Beispiel #11
0
 def authenticate(self, db, user, passwd, client_address):
     try:
         uid = security.login(db, user, passwd)
         if uid is False:
             return False
         return (user, passwd, db, uid)
     except Exception, e:
         netsvc.Logger().notifyChannel("auth", netsvc.LOG_DEBUG,
                                       "Fail auth:" + str(e))
         return False
Beispiel #12
0
 def post(self):
     try:
         data = request.get_json(force=True)
         if internal_login(data['user'], data['password']):
             print('Login success and ready to check both urls!!!!')
             return compare_urls(data['url_1'], data['url_2'])
         else:
             return login(data['user'], data['password'])
     except Exception:
         return request_error()
Beispiel #13
0
 def post(self):
     try:
         data = request.get_json(force=True)
         if internal_login(data['user'], data['password']):
             print('Login success and ready to check words!!!!')
             return compare_text(data['original_text'], data['new_text'])
         else:
             return login(data['user'], data['password'])
     except Exception:
         return request_error()
Beispiel #14
0
def login():
    error = None
    if 'logged_in' in session:
        return redirect(url_for('home'))
    elif request.method == 'POST':
        if security.login(request.form['username'], request.form['password']):
            session['logged_in'] = True
            session['username'] = request.form['username']
            return redirect(url_for('home'))
        else:
            error = 'Invalid Credentials.'
    return render_template('login.html', error=error)
Beispiel #15
0
def route_login():
    form = app_objects.LoginForm()
    login_error_class = 'active'
    if request.method == 'GET' and 'user_name' in session:
        flash('lepj ki, cuni!', 'logged-in-error')
        return redirect(url_for('route_main'))
    elif request.method == 'POST' and form.validate_on_submit(
    ) and security.login(form.username.data, form.password.data):
        session['user_name'] = form.username.data
        session['user_id'] = data_logic.get_user_id_by_username(
            session['user_name'])
        return redirect(url_for('route_main'))
    login_error_class = 'hidden'
    return render_template('login.html',
                           form=form,
                           login_error_class=login_error_class)
Beispiel #16
0
 def post(self):
     try:
         data = request.get_json(force=True)
         return login(data['user'], data['password'])
     except Exception:
         return request_error()