Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = function(sequelize, Sequelize) {
- var User = sequelize.define('User', {
- id: {
- type: Sequelize.INTEGER(11),
- allowNull: true,
- primaryKey: true,
- autoIncrement: true
- },
- user_id: {
- type: Sequelize.STRING(255),
- allowNull: true,
- defaultValue: ''
- }
- }
- User.prototype.getJWT = function () {
- let expiration_time = parseInt(CONFIG.jwt_expiration);
- return "Bearer "+jwt.sign({user_id:this.user_id, role:this.role}, CONFIG.jwt_encryption, {expiresIn: expiration_time});
- }
- return User
- }
- User.create(body).then((user)=>{
- if (user) {
- console.log(user);
- user = user.toWeb()
- user.token = user.getJWT();
- user.message = "Successfully created new user";
- res.json(user);
- }
- }).catch(e=>{
- console.log(e);
- })
Add Comment
Please, Sign In to add comment