0

我在我的项目中实现了ember-simple-auth,但我没有找到任何信息如何添加客户端验证。默认情况下,它将所有请求传递给后端。

sessionAuthenticationFailed函数中,我可以处理来自后端的所有错误,但是如何添加客户端验证?

我的代码在示例中是默认的,但我仍然做错了什么。

登录控制器.coffee

App.LoginController = Em.Controller.extend(SimpleAuth.LoginControllerMixin,
  authenticator: "simple-auth-authenticator:oauth2-password-grant"
)

LoginRoute.coffee

App.LoginRoute = Em.Route.extend

  actions:
    sessionAuthenticationFailed: (response) ->
      console.log 'sessionAuthenticationFailed', response

登录标志

.b-content

  .b-content__body
    form.b-form submit='authenticate'

      Ember.TextField id='identification' valueBinding='identification' class='b-form__input'

      Ember.TextField id='password' type='password' valueBinding='password' class='b-form__input'

      button.b-form__submit.b-button.b-button--primary.ts-submit type='submit'
        | Enter
4

1 回答 1

0

您可以简单地覆盖App.LoginController'authenticate操作,并且仅super在您的客户端验证通过时才调用。

于 2014-09-14T09:59:28.667 回答