小编jmo*_*789的帖子

在mongoose中进行预更新时,user.isModified不是函数

我正在尝试在我正在构建的应用程序中散列密码,并且当我通过调用此函数(coffeesctipt)创建用户时它们正在散列:

UserSchema.pre 'save', (next) ->
  user = this
  hashPass(user, next)

hashPass = (user, next) ->
  # only hash the password if it has been modified (or is new)
  if !user.isModified('password')
    return next()
  # generate a salt
  bcrypt.genSalt SALT_WORK_FACTOR, (err, salt) ->
    if err
      return next(err)
    # hash the password using our new salt
    bcrypt.hash user.password, salt, (err, hash) ->
      if err
        return next(err)
      # override the cleartext password with the hashed one
      user.password = hash
      next()
      return
    return
Run Code Online (Sandbox Code Playgroud)

但是当我做更新并且有这个时:

UserSchema.pre …
Run Code Online (Sandbox Code Playgroud)

schema mongoose mongodb node.js

3
推荐指数
2
解决办法
3746
查看次数

如何判断使用 Node.js 选择了哪个单选按钮

我有一个带有两个单选按钮的表单,我正在使用发布请求并使用主体解析器 npm 包来查看表单输入的值,我在表单上有两个单选按钮,如下所示:

    <p>
      <input class="with-gap" name="group1" type="radio" id="test1" />
      <label for="test1">Teacher</label>
    </p>
    <p>
      <input class="with-gap" name="group1" type="radio" id="test2" />
      <label for="test2">TA</label>
    </p>
Run Code Online (Sandbox Code Playgroud)

唯一的问题是当我 console.log req.body 时,我得到的单选按钮的唯一信息是:

{ group1: 'on' }
Run Code Online (Sandbox Code Playgroud)

它没有告诉我单击了哪个单选按钮,并且我将其中一个名称更改为 group2 它允许用户单击两个单选按钮,那么我如何确定单击了哪个单选按钮?

forms post node.js express body-parser

2
推荐指数
1
解决办法
5293
查看次数

bcrypt在azure应用程序服务上不是有效的win 32应用程序

为了使用Sharp的Node库进行一些图像处理,我必须将Azure App Service上的node可执行文件升级到64位。我是通过手动下载可执行文件,然后在中设置其路径来实现的IISNode.yml。

不幸的是,当我启动该应用程序时,它引发以下错误:

应用程序引发了未捕获的异常并被终止:错误:%1不是有效的Win32应用程序。

\\?\D:\home\site\wwwroot\node_modules\bcrypt\build\Release\bcrypt_lib.node
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.cls_wrapMethod [as _load] (D:\home\site\wwwroot\node_modules\newrelic\lib\shimmer.js:256:38)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at bindings (D:\home\site\wwwroot\node_modules\bindings\bindings.js:76:44)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\bcrypt\bcrypt.js:3:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.cls_wrapMethod [as _load] (D:\home\site\wwwroot\node_modules\newrelic\lib\shimmer.js:256:38)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\bookshelf-bcrypt\index.js:5:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
Run Code Online (Sandbox Code Playgroud)

我正在使用Appveyor CI系统构建和部署应用程序。这是我 …

azure bcrypt node.js appveyor

2
推荐指数
1
解决办法
1866
查看次数

在Vue中你可以从方法中调用created()函数吗?

所以我正在使用vue创建一个应用程序,在页面加载时它需要一个带有用户zip的cookie并使用该zip执行搜索,但是如果用户的错误,也允许用户更改该zip,所以我希望能够调用从更改zip时运行的常规方法内部创建的方法是否可以在Vue中实现?

javascript javascript-framework vue.js

2
推荐指数
1
解决办法
68
查看次数

垫排序在角度垫表中不起作用

我的 mat-table 工作正常,但是当按照官方 api 文档添加 mat-sort 时,它在 ngAfterViewInit 处失败,并显示以下消息

无法设置未定义 aq LeadsComponent.push../src/app/leads/leads.component.ts.LeadsComponent.ngAfterViewInit 的属性“排序”

已经有一篇关于 Mat-table Sorting Demo 的帖子并尝试了它们,但我仍然无法让它工作。

有人可以帮我解决这个问题吗?官方示例使用组件本身定义的“静态”MatTableDataSource,但是我正在从后端进行查询。

MatSortModule 已经导入到 app.module.ts 中,mat-sort-header 指令应用于列,并且 ngAfterViewInit 已经与官方示例中的完全相同......

 export class LeadsComponent implements OnInit,AfterViewInit  {

  displayedColumns: string[] = ['name', 'leadStatus', 'mobile', 'email', 'actions'];
  dataSource: MatTableDataSource<LeadsChildObject>;
  @ViewChild(MatPaginator) paginator: MatPaginator;
  @ViewChild(MatSort) sort: MatSort;

  constructor(public dialog: MatDialog, private dashBoardService: LeadsService,
    private toast: ToastrService) {
  }

    ngAfterViewInit() {
        this.dataSource.sort = this.sort;
      }

      ngOnInit() {
        this.dashboardService.getFeedback.subscribe(
          res => {
            this.leadlist= res;
            this.dataSource = new MatTableDataSource(this.leadlist);
          }
        );
      } …
Run Code Online (Sandbox Code Playgroud)

angular-material angular angular-material-table

2
推荐指数
1
解决办法
1万
查看次数

造型角材料分页器

我有一个看起来像的角材料分页器

在此处输入图片说明

我想样式,它应该看起来像

在此处输入图片说明

我现在很难设计它的样式。我只是能够移动分页器中的元素(开始和结束位置),除此之外,我无法进行任何修改。

请让我知道如何做所需的样式?

这是stackblitz链接https://stackblitz.com/edit/angular-tjhkpo

html css angular-material angular angular-material-paginator

1
推荐指数
1
解决办法
2068
查看次数