mirror of
https://github.com/flarum/framework.git
synced 2025-05-21 22:36:01 +08:00
Improve client XHR error handling
The default XHR error handler produce an alert which is appropriate to the response status code. It can be overridden per-request (by specifying the `errorHandler` option) so that the alert can be suppressed or displayed in a different position (e.g. inside a modal). ref #118
This commit is contained in:
@ -26,15 +26,16 @@ export default class Session {
|
||||
*
|
||||
* @param {String} identification The username/email.
|
||||
* @param {String} password
|
||||
* @param {Object} [options]
|
||||
* @return {Promise}
|
||||
* @public
|
||||
*/
|
||||
login(identification, password) {
|
||||
return app.request({
|
||||
login(identification, password, options = {}) {
|
||||
return app.request(Object.assign({
|
||||
method: 'POST',
|
||||
url: app.forum.attribute('baseUrl') + '/login',
|
||||
data: {identification, password}
|
||||
})
|
||||
}, options))
|
||||
.then(() => window.location.reload());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user