everyauth:如何从validateRegistration返回表单数据

时间:2013-12-12 12:31:16

标签: node.js express everyauth

我使用everyauth的密码模块,并在validateRegistration方法中注册时进行一些验证,推送一些错误,履行承诺并将其返回。但是这样我在视图中缺少表单数据(即输入的电子邮件,名字,姓氏等),用户必须再次输入。

这是我的validateRegistration方法:

.validateRegistration (newUserAttrs, errors) ->
  login = newUserAttrs.email;
  promise = @Promise()

  if !newUserAttrs.name.first
      errors.push 'Missing first name'

  if !newUserAttrs.name.last
     errors.push 'Missing last name'

  userManager.getUser "Custom", login, (user, err) ->
    if user
      errors.push('User with the same email already exists!')      
    promise.fulfill errors

  return promise

我的玉视图

form(action='/register', method='POST')
    label(for='firstName') First Name
    input(type='text', name='firstName')    

    label(for='lastName') Last Name
    input(type='text', name='lastName')    

    label(for=everyauth.password.loginFormFieldName) Email
    input(type='text', name=everyauth.password.loginFormFieldName)

    label(for=everyauth.password.passwordFormFieldName) Password
    input(type='password', name=everyauth.password.passwordFormFieldName)

您有什么建议我如何将表单数据传回视图,以便填写表单字段?

由于

0 个答案:

没有答案