[REM] web: /login route
Only used by web tests (which rely on a module they don't depend on to run, bad!) and altering the test session directly should work, so this endpoint seems completely unnecessary.
This commit is contained in:
committed by
Olivier Dony
parent
cea29e0c01
commit
afa9f4b5fd
@@ -565,12 +565,6 @@ class Home(http.Controller):
|
||||
values['error'] = "Wrong login/password"
|
||||
return request.render('web.login', values)
|
||||
|
||||
@http.route('/login', type='http', auth="none")
|
||||
def login(self, db, login, key, redirect="/web", **kw):
|
||||
if not http.db_filter([db]):
|
||||
return werkzeug.utils.redirect('/', 303)
|
||||
return login_and_redirect(db, login, key, redirect_url=redirect)
|
||||
|
||||
class WebClient(http.Controller):
|
||||
|
||||
@http.route('/web/webclient/csslist', type='json', auth="none")
|
||||
|
||||
+25
-6
@@ -269,10 +269,28 @@ class HttpCase(TransactionCase):
|
||||
return self.opener.open(url, data, timeout)
|
||||
|
||||
def authenticate(self, user, password):
|
||||
if user is not None:
|
||||
url = '/login?%s' % werkzeug.urls.url_encode({'db': get_db_name(),'login': user, 'key': password})
|
||||
auth = self.url_open(url)
|
||||
assert auth.getcode() < 400, "Auth failure %d" % auth.getcode()
|
||||
# stay non-authenticated
|
||||
if user is None:
|
||||
return
|
||||
|
||||
db = get_db_name()
|
||||
Users = self.registry['res.users']
|
||||
uid = Users.authenticate(db, user, password, None)
|
||||
|
||||
# self.session.authenticate(db, user, password, uid=uid)
|
||||
# OpenERPSession.authenticate accesses the current request, which we
|
||||
# don't have, so reimplement it manually...
|
||||
session = self.session
|
||||
|
||||
session.db = db
|
||||
session.uid = uid
|
||||
session.login = user
|
||||
session.password = password
|
||||
session.context = Users.context_get(self.cr, uid) or {}
|
||||
session.context['uid'] = uid
|
||||
session._fix_lang(session.context)
|
||||
|
||||
openerp.http.root.session_store.save(session)
|
||||
|
||||
def phantom_poll(self, phantom, timeout):
|
||||
""" Phantomjs Test protocol.
|
||||
@@ -401,11 +419,12 @@ class HttpCase(TransactionCase):
|
||||
'code': code,
|
||||
'ready': ready,
|
||||
'timeout' : timeout,
|
||||
'login' : login,
|
||||
'session_id': self.session_id,
|
||||
}
|
||||
options.update(kw)
|
||||
options.setdefault('password', options.get('login'))
|
||||
|
||||
self.authenticate(login, login)
|
||||
|
||||
phantomtest = os.path.join(os.path.dirname(__file__), 'phantomtest.js')
|
||||
cmd = ['phantomjs', phantomtest, json.dumps(options)]
|
||||
self.phantom_run(cmd, timeout)
|
||||
|
||||
@@ -102,14 +102,6 @@ function PhantomTest() {
|
||||
// run test
|
||||
// ----------------------------------------------------
|
||||
this.run = function(url_path, code, ready) {
|
||||
if(self.options.login) {
|
||||
var qp = [];
|
||||
qp.push('db=' + self.options.db);
|
||||
qp.push('login=' + self.options.login);
|
||||
qp.push('key=' + self.options.password);
|
||||
qp.push('redirect=' + encodeURIComponent(url_path));
|
||||
url_path = "/login?" + qp.join('&');
|
||||
}
|
||||
var url = self.origin + url_path;
|
||||
code = code || "true";
|
||||
ready = ready || "true";
|
||||
|
||||
Reference in New Issue
Block a user