Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { compareSync, genSaltSync, hashSync } from 'bcrypt';
- import { Document, Schema, model } from 'mongoose';
- export class User {
- username: string;
- password: string;
- isValidPassword(password: string): boolean {
- return compareSync(password, this.password)
- }
- }
- let userSchema = new Schema({
- username: { required: true, type: String },
- password: { required: true, type: String }
- }, { timestamps: true });
- userSchema.pre('save', function (next) {
- this.password = hashSync(this.password, genSaltSync(8));
- next();
- });
- export interface UserDocument extends User, Document {}
- export const Users = model<UserDocument>('User', userSchema);
- (function (global) {
- System.config({
- map: {
- '@angular': 'node_modules/@angular',
- 'bcrypt': 'node_modules/bcrypt',
- 'bindings': 'node_modules/bindings',
- 'mongoose': 'node_modules/mongoose',
- 'rxjs': 'node_modules/rxjs'
- },
- paths: {
- 'node_modules/@angular/*': 'node_modules/@angular/*/bundles'
- },
- meta: {
- '@angular/*': {'format': 'cjs'}
- },
- packages: {
- 'src': {main: 'main', defaultExtension: 'js'},
- '@angular/core': {main: 'core.umd.min.js'},
- '@angular/common': {main: 'common.umd.min.js'},
- '@angular/compiler': {main: 'compiler.umd.min.js'},
- '@angular/forms': {main: 'forms.umd.min.js'},
- '@angular/http': {main: 'http.umd.min.js'},
- '@angular/platform-browser': {main: 'platform-browser.umd.min.js'},
- '@angular/platform-browser-dynamic': {main:'platform-browser-dynamic.umd.min.js'},
- 'bcrypt': {main: 'bCrypt.js'},
- 'mongoose': {main: 'index.js'},
- 'rxjs': {defaultExtension: 'js'}
- }
- });
- }(this));
- {
- "globalDependencies": {
- "bcrypt": "registry:dt/bcrypt#0.0.0+20160316155526",
- "core-js": "registry:dt/core-js#0.0.0+20160914114559",
- "jasmine": "registry:dt/jasmine#2.5.0+20161003201800",
- "mongodb": "registry:dt/mongodb#2.1.0+20160602142941",
- "mongoose": "registry:dt/mongoose#4.5.9+20161010180758",
- "node": "registry:dt/node#6.0.0+20161014191813"
- }
- }
- 1274 GET http://localhost:8080/crypto 404 (Not Found)
- http://localhost:8080/node_modules/mongoose/lib.js 404 (Not Found)
- http://localhost:8080/node_modules/bindings/ 404 (Not Found)
- 'bindings': 'node_modules/bindings'
- 'bindings': {main: 'bindings.js'},
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement