简体   繁体   English

ember-simple-auth在开发过程中使用的存根身份验证服务器

[英]Stub authentication server used by ember-simple-auth during development

I'm using ember-simple-auth in my emberjs app to authenticate via oauth2-password-grant with my own (currently unimplemented) service. 我在我的emberjs应用程序中使用ember-simple-auth使用我自己的(当前未实现的)服务通过oauth2-password-grant进行身份验证。

I'd like to continue developing the front-end before creating the authentication service. 我想在创建身份验证服务之前继续开发前端。

Can the authentication service be stubbed so login/logout features can be used? 可以对身份验证服务进行存根以便可以使用登录/注销功能吗? I'm aware that I mock it with http-mock during tests, but I would also like to work on the front-end design and view it in the browser. 我知道我在测试过程中使用http-mock对其进行了模拟,但是我也想进行前端设计并在浏览器中进行查看。

HTTP mocks also run during development. HTTP模拟还在开发过程中运行。 You can also use Pretender or Mirage (a library built on top of Pretender) to clientside mocks. 您还可以使用PretenderMirage (基于Pretender构建的库)进行客户端模拟。

In Mirage your route may look something like this: 在Mirage中,您的路线可能如下所示:

// app/mirage/config.js
this.post('/users/sign_in', (db, request) => {
  return {
    user_email: "some.user@gmail.com",
    user_id: 1,
    user_token: "LcsBEYP2yjTcc-G7drto"
  };
});

depending on the shape of your backend response. 取决于您的后端响应的形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM