UserResource extends AuthorizedResource
rest-io
supports User authentication.
To create a user resource:
import { Schema } from 'mongoose';
import { UserResource } from 'rest-io';
export const user = new UserResource({
name: 'user',
model: {
userName: String,
password: String,
roles: [{
type: Schema.Types.ObjectId,
ref: 'Role'
}],
// Add your additional user properties here
personalGreeting: String
}
});
These are the functions you can overwrite or use:
Creates a basic Role model, containing only the name of the Role.
Checks if the logged in user is performing an action on it's own resource.
Logs a user in. The password is stored encrypted in the database. More information about authorization. The credentials are passed via the json body:
{
"userName": "EnoF",
"password": "secret"
}