1
votes

I want to configure the Ember Simple Auth session to be authenticated for a user generated by Ember CLI Mirage on startup. During testing I can use the Ember Simple Auth authenticateSession() helper, but as far as I can tell, this isn't available during development. Is there a way to update the session before the app boots?

1
How does your app authenticate? For example, does it POST to your backend with a username and password? If so you should be able to fake out that route in Mirage.Sam Selikoff
It gets a bearer token (and some user metadata) from an authentication route, but only where the user first logs in. That metadata is kept in localstorage and reused. That's the stuff I want to replace.cbnz

1 Answers

0
votes

If you're just looking to change the behavior of Ember Simple Auth on the client and in a situation where your Ember app never makes an XHR request, Mirage won't be able to help you out here. You could fake the login request (which may set some user data), but if you want to change the logged-in user without going through xhr authentication, you'll need to use environment-based config to change how Simple Auth behaves.

(I know this is not a complete answer to your question, I just wanted to point out that Mirage only knows how to handle XHR requests, and it sounds like your problem involves client-side state.)