[英]How to add client side validation to ember-simple-auth
I implemented ember-simple-auth to my project but I didn't find any info how to add client side validation to it. 我在项目中实现了ember-simple-auth ,但没有找到有关如何向其添加客户端验证的信息。 By default it pass all requests to backend. 默认情况下,它将所有请求传递给后端。
In sessionAuthenticationFailed function I can handle all errors from backend but how I can add client-side validation? 在sessionAuthenticationFailed函数中,我可以处理来自后端的所有错误,但是如何添加客户端验证?
My code is default in example but still mb I do something wrong. 在示例中,我的代码是默认代码,但是mb我还是做错了。
LoginController.coffee LoginController.coffee
App.LoginController = Em.Controller.extend(SimpleAuth.LoginControllerMixin,
authenticator: "simple-auth-authenticator:oauth2-password-grant"
)
LoginRoute.coffee LoginRoute.coffee
App.LoginRoute = Em.Route.extend
actions:
sessionAuthenticationFailed: (response) ->
console.log 'sessionAuthenticationFailed', response
login.emblem login.emblem
.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
您可以简单地覆盖App.LoginController
的authenticate
操作,并且仅在客户端验证通过时才调用super
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.