Sails Actions2退出自定义消息

时间:2019-08-19 06:59:58

标签: node.js sails.js

我只是将Passport添加到我的Sails应用程序中。我想使用带有req.flash的操作中的退出功能设置自定义消息。

是否有可能从响应页面获取exits方法的描述?

以同样的方式,当badRequest响应上的输入不正确时,是否有可能获得错误消息,并在同一页面上将其闪烁而不是重定向到响应页面。

谢谢您的帮助

  inputs: {
    username: {
      description: 'The username of the user to look up.',
      // By declaring a string example, Sails will automatically respond with `res.badRequest`
      // if the `username` parameter is not a string.
      type: 'string',
      // By making the `username` parameter required, Sails will automatically respond with
      // `res.badRequest` if it's left out.
      required: true
    },
    password: {
      description: 'The passowrd of the user to authenticate.',
      type: 'string',
      required: true
    }
  },

  exits: {
    success: {
      responseType: 'view',
      viewTemplatePath: 'pages/homepage'
    },
    invalid: {
      description: 'The username or password are missing or invalid.',
      extendedDescription: 'If this request was sent from a graphical user interface, the request ' +
        'parameters should have been validated/coerced _before_ they were sent.',
      responseType: 'authenticationFailed',
    },
    notFound: {
      description: 'No user with the specified ID was found in the database.',
      responseType: 'authenticationFailed',
    },
    authenticationFailed: {
      description: 'Bad credentials',
      responseType: 'authenticationFailed',
    }
  },

0 个答案:

没有答案