Created
November 27, 2014 02:35
-
-
Save scarvell/09cd5fa184739bdfe978 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function User (userData) { | |
this.id = userData.id; | |
this.firstName = userData.firstName; | |
this.lastName = userData.lastName; | |
this.displayName = this.firstName + " " + this.lastName; | |
this.email = userData.email; | |
this.admin = userData.admin || 0; | |
this.checkRights = function (code) { | |
if (this.isAdmin()) return true; | |
return (this.rights.split(',').indexOf(code)) ? true : false; | |
}; | |
this.isAdmin = function () { | |
return (this.admin == 1) ? true : false; | |
} | |
} | |
var users = [ | |
{firstName: 'Brendan', lastName: 'Scarvell', email: '[email protected]', admin: 1}, | |
{firstName: 'Foo', lastName: 'Bar', email: '[email protected]', admin: 0}, | |
{firstName: 'Chloe', lastName: 'Dog', email: '[email protected]', admin: 1}, | |
]; | |
users = users.map(function(u){ return new User(u); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment