[FIX] web: do not crash when select wrong db
When a user tries to log into a postgresql database with no view web.login (this happens if the database is not an odoo database or using a previous version of odoo), the rendering failed, producing a 500 error (with no detail for the user) Instead, redirect to the database selector with an informative message. Fixes #3443 The database selector page is a jinja template with no access to database required so should be able to be displayed on any database. Future improvement could verify the version of base module for even more precise verification before login (but need to make sure it's always accurate).
This commit is contained in:
parent
4d7671a4c3
commit
87d48b0859
|
@ -511,7 +511,13 @@ class Home(http.Controller):
|
|||
return http.redirect_with_hash(redirect)
|
||||
request.uid = old_uid
|
||||
values['error'] = "Wrong login/password"
|
||||
return request.render('web.login', values)
|
||||
if request.env.ref('web.login', False):
|
||||
return request.render('web.login', values)
|
||||
else:
|
||||
# probably not an odoo compatible database
|
||||
error = 'Unable to login on database %s' % request.session.db
|
||||
return werkzeug.utils.redirect('/web/database/selector?error=%s' % error, 303)
|
||||
|
||||
|
||||
@http.route('/login', type='http', auth="none")
|
||||
def login(self, db, login, key, redirect="/web", **kw):
|
||||
|
@ -664,6 +670,7 @@ class Database(http.Controller):
|
|||
return env.get_template("database_selector.html").render({
|
||||
'databases': dbs,
|
||||
'debug': request.debug,
|
||||
'error': kw.get('error')
|
||||
})
|
||||
|
||||
@http.route('/web/database/manager', type='http', auth="none")
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
|
||||
<hr/>
|
||||
|
||||
{% if error %}
|
||||
<p class="alert alert-danger">
|
||||
{{ error }}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group field-db">
|
||||
<label for="db" class="control-label">Select database</label>
|
||||
{% if databases %}
|
||||
|
|
Loading…
Reference in New Issue