mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
parent
8e9b27f0b5
commit
89201a5c84
3 changed files with 19 additions and 4 deletions
|
@ -61,7 +61,7 @@ User = ghostBookshelf.Model.extend({
|
||||||
saving: function () {
|
saving: function () {
|
||||||
|
|
||||||
this.set('name', this.sanitize('name'));
|
this.set('name', this.sanitize('name'));
|
||||||
this.set('email', this.sanitize('email'));
|
this.set('email', this.sanitize('email').toLocaleLowerCase());
|
||||||
this.set('location', this.sanitize('location'));
|
this.set('location', this.sanitize('location'));
|
||||||
this.set('website', this.sanitize('website'));
|
this.set('website', this.sanitize('website'));
|
||||||
this.set('bio', this.sanitize('bio'));
|
this.set('bio', this.sanitize('bio'));
|
||||||
|
@ -154,7 +154,7 @@ User = ghostBookshelf.Model.extend({
|
||||||
// Finds the user by email, and checks the password
|
// Finds the user by email, and checks the password
|
||||||
check: function (_userdata) {
|
check: function (_userdata) {
|
||||||
return this.forge({
|
return this.forge({
|
||||||
email: _userdata.email
|
email: _userdata.email.toLocaleLowerCase()
|
||||||
}).fetch({require: true}).then(function (user) {
|
}).fetch({require: true}).then(function (user) {
|
||||||
return nodefn.call(bcrypt.compare, _userdata.pw, user.get('password')).then(function (matched) {
|
return nodefn.call(bcrypt.compare, _userdata.pw, user.get('password')).then(function (matched) {
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
|
|
|
@ -48,6 +48,21 @@ describe('User Model', function run() {
|
||||||
}).then(null, done);
|
}).then(null, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can lowercase email', function (done) {
|
||||||
|
var userData = testUtils.DataGenerator.forModel.users[2],
|
||||||
|
gravatarStub = sinon.stub(UserModel, 'gravatarLookup', function (userData) {
|
||||||
|
return when.resolve(userData);
|
||||||
|
});
|
||||||
|
|
||||||
|
UserModel.add(userData).then(function (createdUser) {
|
||||||
|
should.exist(createdUser);
|
||||||
|
createdUser.has('uuid').should.equal(true);
|
||||||
|
createdUser.attributes.email.should.eql(userData.email.toLocaleLowerCase(), "email address correct");
|
||||||
|
gravatarStub.restore();
|
||||||
|
done();
|
||||||
|
}).then(null, done);
|
||||||
|
});
|
||||||
|
|
||||||
it('can find gravatar', function (done) {
|
it('can find gravatar', function (done) {
|
||||||
var userData = testUtils.DataGenerator.forModel.users[4],
|
var userData = testUtils.DataGenerator.forModel.users[4],
|
||||||
gravatarStub = sinon.stub(UserModel, 'gravatarLookup', function (userData) {
|
gravatarStub = sinon.stub(UserModel, 'gravatarLookup', function (userData) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ DataGenerator.Content = {
|
||||||
{
|
{
|
||||||
name: 'Jimothy Bogendath',
|
name: 'Jimothy Bogendath',
|
||||||
slug: 'jimothy-bogendath',
|
slug: 'jimothy-bogendath',
|
||||||
email: 'jbogendath@example.com',
|
email: 'jbOgendAth@example.com',
|
||||||
password: '$2a$10$.pZeeBE0gHXd0PTnbT/ph.GEKgd0Wd3q2pWna3ynTGBkPKnGIKZL6'
|
password: '$2a$10$.pZeeBE0gHXd0PTnbT/ph.GEKgd0Wd3q2pWna3ynTGBkPKnGIKZL6'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -220,4 +220,4 @@ DataGenerator.forModel = (function () {
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
module.exports = DataGenerator;
|
module.exports = DataGenerator;
|
||||||
|
|
Loading…
Add table
Reference in a new issue