-
Notifications
You must be signed in to change notification settings - Fork 2
user
superafroman edited this page Oct 13, 2010
·
2 revisions
A user is an object with a username, password and array of roles. These properties are accessed by connect-security through get methods so the properties don't necessarily have to be part of your domain, e.g. if rather than a username you use an email address you may have a user object with
function getUsername() {
return this.emailAddress;
}
A basic user object (and the user used by the InMemoryUserProvider) would look something like
function User(username, password, roles) {
this.username = username;
this.password = password;
this.roles = roles;
}
User.prototype.getUsername = function() {
return this.username;
}
User.prototype.getPassword = function() {
return this.password;
}
User.prototype.getRoles = function() {
return this.roles;
}
Roles are just Strings that define what role(s) a user has within your application. They are used to restrict access to certain areas of your application. For example the following would only print to the console for users with the role 'admin'.
security.secure('admin', request, function() {
console.log('user has admin privileges');
});