Skip to content

Commit 2379b41

Browse files
committed
fix(login): show error message from login results on login failure.
1 parent 9de2157 commit 2379b41

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

lib/ionic/login.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ function login(argv) {
4545
return cookieJar;
4646
})
4747
.catch(function(ex) {
48-
log.error('Error logging in');
49-
throw ex;
50-
51-
// log.info(ex);
52-
// log.info(ex.stack);
48+
log.error(ex);
5349
});
5450
}
5551

spec/tasks/login.spec.js

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,18 @@ describe('login command', function() {
118118
});
119119
});
120120

121-
it('should throw an error on a failed log in', function(done) {
121+
it('should display the error on a failed log in attempt', function(done) {
122122
var processArguments = ['node', 'ionic', 'login', '--email', '[email protected]', '--password', 'asdf1234'];
123123
var rawCliArguments = processArguments.slice(2);
124124
var argv = optimist(rawCliArguments).argv;
125125

126-
var error = new Error('error occurred');
126+
var error = 'Email or Password incorrect. Please visit';
127127
spyOn(log, 'error');
128128
spyOn(login, 'promptForLogin');
129-
spyOn(appLibLogin, 'requestLogIn').andCallFake(function() {
130-
throw error;
131-
});
129+
spyOn(appLibLogin, 'requestLogIn').andReturn(Q.reject(error));
132130

133-
login.login(argv).catch(function(err) {
134-
expect(log.error).toHaveBeenCalledWith('Error logging in');
135-
expect(err).toEqual(error);
131+
login.login(argv).then(function() {
132+
expect(log.error).toHaveBeenCalledWith(error);
136133
done();
137134
});
138135
});
@@ -159,25 +156,5 @@ describe('login command', function() {
159156
done();
160157
});
161158
});
162-
163-
it('should return a rejected promise on failure', function(done) {
164-
var processArguments = ['node', 'ionic', 'login'];
165-
var rawCliArguments = processArguments.slice(2);
166-
var argv = optimist(rawCliArguments).argv;
167-
168-
spyOn(log, 'info');
169-
spyOn(prompt, 'start');
170-
spyOn(prompt, 'get').andCallFake(function(schema, callback) {
171-
callback('an error occurred', null);
172-
});
173-
174-
var promptForLogin = login.__get__('promptForLogin');
175-
176-
promptForLogin(argv).catch(function(results) {
177-
expect(prompt.get).toHaveBeenCalled();
178-
expect(results).toEqual('Error logging in: an error occurred');
179-
done();
180-
});
181-
});
182159
});
183160
});

0 commit comments

Comments
 (0)