mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Make sure password is last
This commit is contained in:
committed by
Avital Oliver
parent
6356b73ef8
commit
09d5c94522
@@ -1,11 +1,23 @@
|
||||
Tinytest.add(
|
||||
'accounts-ui - getLoginServices retuns an array of service hashes',
|
||||
function (test) {
|
||||
// setup
|
||||
var services;
|
||||
Accounts._loginButtons.loginServices.push('password');
|
||||
services = Accounts._loginButtons.getLoginServices();
|
||||
(function(environment) {
|
||||
// setup
|
||||
Accounts._loginButtons.loginServices.push('password');
|
||||
environment.meteorServices = function() {
|
||||
return Accounts._loginButtons.getLoginServices();
|
||||
};
|
||||
|
||||
Tinytest.add(
|
||||
'accounts-ui - getLoginServices retuns an array of service hashes',
|
||||
function (test) {
|
||||
test.equal(_.first(environment.meteorServices()), {name: "password"});
|
||||
}
|
||||
);
|
||||
|
||||
Tinytest.add(
|
||||
'accounts-ui - getLoginServices should always return password last',
|
||||
function (test) {
|
||||
Accounts._loginButtons.loginServices.push('some_other_service');
|
||||
test.equal(_.last(environment.meteorServices()), {name: "password"});
|
||||
}
|
||||
);
|
||||
})(Tinytest);
|
||||
|
||||
test.equal(_.first(services), {name: "password"});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -119,7 +119,17 @@
|
||||
|
||||
Accounts._loginButtons.getLoginServices = function () {
|
||||
var self = this,
|
||||
services = self.loginServices;
|
||||
services = self.loginServices, // memoize services array
|
||||
passwordIndex = services.indexOf("password"), // memoize password idx.
|
||||
lastServiceAt = services.length - 1; // memoize last service idx.
|
||||
|
||||
// make sure to put password last, since this is how it is styled
|
||||
// if we had found password, swap w last service
|
||||
if (passwordIndex !== -1) {
|
||||
services[lastServiceAt] = services[passwordIndex];
|
||||
services[passwordIndex] = services[lastServiceAt];
|
||||
}
|
||||
|
||||
return _.map(services, function(service) {
|
||||
return {name: service};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user