Advertisement
Guest User

Untitled

a guest
Oct 16th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. import { compareSync, genSaltSync, hashSync } from 'bcrypt';
  2. import { Document, Schema, model } from 'mongoose';
  3.  
  4. export class User {
  5. username: string;
  6. password: string;
  7.  
  8. isValidPassword(password: string): boolean {
  9. return compareSync(password, this.password)
  10. }
  11. }
  12.  
  13. let userSchema = new Schema({
  14. username: { required: true, type: String },
  15. password: { required: true, type: String }
  16. }, { timestamps: true });
  17.  
  18. userSchema.pre('save', function (next) {
  19. this.password = hashSync(this.password, genSaltSync(8));
  20. next();
  21. });
  22.  
  23. export interface UserDocument extends User, Document {}
  24.  
  25. export const Users = model<UserDocument>('User', userSchema);
  26.  
  27. (function (global) {
  28. System.config({
  29. map: {
  30. '@angular': 'node_modules/@angular',
  31. 'bcrypt': 'node_modules/bcrypt',
  32. 'bindings': 'node_modules/bindings',
  33. 'mongoose': 'node_modules/mongoose',
  34. 'rxjs': 'node_modules/rxjs'
  35. },
  36. paths: {
  37. 'node_modules/@angular/*': 'node_modules/@angular/*/bundles'
  38. },
  39. meta: {
  40. '@angular/*': {'format': 'cjs'}
  41. },
  42. packages: {
  43. 'src': {main: 'main', defaultExtension: 'js'},
  44. '@angular/core': {main: 'core.umd.min.js'},
  45. '@angular/common': {main: 'common.umd.min.js'},
  46. '@angular/compiler': {main: 'compiler.umd.min.js'},
  47. '@angular/forms': {main: 'forms.umd.min.js'},
  48. '@angular/http': {main: 'http.umd.min.js'},
  49. '@angular/platform-browser': {main: 'platform-browser.umd.min.js'},
  50. '@angular/platform-browser-dynamic': {main:'platform-browser-dynamic.umd.min.js'},
  51. 'bcrypt': {main: 'bCrypt.js'},
  52. 'mongoose': {main: 'index.js'},
  53. 'rxjs': {defaultExtension: 'js'}
  54. }
  55. });
  56. }(this));
  57.  
  58. {
  59. "globalDependencies": {
  60. "bcrypt": "registry:dt/bcrypt#0.0.0+20160316155526",
  61. "core-js": "registry:dt/core-js#0.0.0+20160914114559",
  62. "jasmine": "registry:dt/jasmine#2.5.0+20161003201800",
  63. "mongodb": "registry:dt/mongodb#2.1.0+20160602142941",
  64. "mongoose": "registry:dt/mongoose#4.5.9+20161010180758",
  65. "node": "registry:dt/node#6.0.0+20161014191813"
  66. }
  67. }
  68.  
  69. 1274 GET http://localhost:8080/crypto 404 (Not Found)
  70. http://localhost:8080/node_modules/mongoose/lib.js 404 (Not Found)
  71. http://localhost:8080/node_modules/bindings/ 404 (Not Found)
  72.  
  73. 'bindings': 'node_modules/bindings'
  74.  
  75. 'bindings': {main: 'bindings.js'},
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement