From 82435937164e1ae117033352c3e5b480cb88508f Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Mon, 20 Nov 2017 15:27:34 -0200 Subject: [PATCH] message on invalid password --- app/lib/rocketchat.js | 25 +++++-------------------- app/sagas/login.js | 6 +----- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index f86ed3884..a4acb77d3 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -92,6 +92,11 @@ const RocketChat = { Meteor._endLoggingIn(); Meteor._handleLoginCallback(err, result); if (err) { + if (/user not found/i.test(err.reason)) { + err.error = 1; + err.reason = 'User or Password incorrect'; + err.message = 'User or Password incorrect'; + } reject(err); } else { resolve(result); @@ -168,26 +173,6 @@ const RocketChat = { return this.login(params, callback); }, - // loadRooms(cb) { - // console.warn('a'); - // Meteor.call('rooms/get', (err, data) => { - // if (err) { - // console.error(err); - // } - // console.warn(`rooms ${ data.length }`); - // if (data.length) { - // realm.write(() => { - // data.forEach((room) => { - // room._server = { id: reduxStore.getState().server.server }; - // realm.create('rooms', room, true); - // }); - // }); - // } - - // return cb && cb(); - // }); - // }, - loadSubscriptions(cb) { Meteor.call('subscriptions/get', (err, data) => { if (err) { diff --git a/app/sagas/login.js b/app/sagas/login.js index 36d1383c2..f3d83d28a 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -83,11 +83,7 @@ const handleLoginRequest = function* handleLoginRequest({ credentials }) { yield put(loginSuccess(user)); } catch (err) { - if (err.error === 403) { - yield put(logout()); - } else { - yield put(loginFailure(err)); - } + yield put(loginFailure(err)); } };