mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Fixed auth tests. Updated Authctrl response
This commit is contained in:
@@ -25,7 +25,7 @@ describe('Auth Controller', function() {
|
|||||||
describe('logging in', function() {
|
describe('logging in', function() {
|
||||||
|
|
||||||
it('should log in users with correct uname / pass', function() {
|
it('should log in users with correct uname / pass', function() {
|
||||||
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
|
$httpBackend.expectPOST('/api/v3/user/auth/local/login').respond({data: {id: 'abc', apiToken: 'abc'}});
|
||||||
scope.auth();
|
scope.auth();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
expect(user.authenticate).to.be.calledOnce;
|
expect(user.authenticate).to.be.calledOnce;
|
||||||
@@ -33,7 +33,7 @@ describe('Auth Controller', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not log in users with incorrect uname / pass', function() {
|
it('should not log in users with incorrect uname / pass', function() {
|
||||||
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
|
$httpBackend.expectPOST('/api/v3/user/auth/local/login').respond(404, '');
|
||||||
scope.auth();
|
scope.auth();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
expect(user.authenticate).to.not.be.called;
|
expect(user.authenticate).to.not.be.called;
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ angular.module('habitrpg')
|
|||||||
|
|
||||||
function errorAlert(data, status, headers, config) {
|
function errorAlert(data, status, headers, config) {
|
||||||
$scope.registrationInProgress = false;
|
$scope.registrationInProgress = false;
|
||||||
|
console.log(data)
|
||||||
if (status === 0) {
|
if (status === 0) {
|
||||||
$window.alert(window.env.t('noReachServer'));
|
$window.alert(window.env.t('noReachServer'));
|
||||||
} else if (!!data && !!data.err) {
|
} else if (!!data && !!data.error) {
|
||||||
$window.alert(data.data.message);
|
$window.alert(data.message);
|
||||||
} else {
|
} else {
|
||||||
$window.alert(window.env.t('errorUpCase') + ' ' + status);
|
$window.alert(window.env.t('errorUpCase') + ' ' + status);
|
||||||
}
|
}
|
||||||
@@ -104,7 +105,7 @@ angular.module('habitrpg')
|
|||||||
runAuth(data.data.id, data.data.apiToken);
|
runAuth(data.data.id, data.data.apiToken);
|
||||||
}).error(errorAlert);
|
}).error(errorAlert);
|
||||||
}, function( e ){
|
}, function( e ){
|
||||||
alert("Signin error: " + e.error.message );
|
alert("Signin error: " + e.message );
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user