0

I have an action that retrieves some data from the DB and then I wanted to check that the data it have received is correct before it continues on with authentication. I am using invite codes to allow people to log into a public site that is for private corporate use only. I am able to get the data just fine, but the aftermodel is firing before the request is completed. I am making a call to an azure mobile service and the call is still in pending (according to chrome) when the aftermodel is firing off. Seems like it hasn't received the data at that point.

What is the best method to get this verification working properly? Once it verifies it would then allow them to log in with an external provider.

Woundedbear
  • 277
  • 1
  • 3
  • 13

1 Answers1

0

Please, look at this discussion: Ember authentication best practices?

If you don't need an Auth engine, then you could implement "verifying data" in beforeModel hook. Why beforeModel? Because if data is not correct, then app should redirect user to another page, and beforeModel is made for this logic: http://emberjs.com/guides/routing/preventing-and-retrying-transitions/#toc_aborting-transitions-within-code-model-code-code-beforemodel-code-code-aftermodel-code

Community
  • 1
  • 1
Microfed
  • 2,832
  • 22
  • 25
  • I am verifying this against an invite code that is housed in a table in azure mobile services. How can I validate the invite token this way? I thought beforemodel was triggered before the query would happen. – Woundedbear Mar 22 '14 at 04:15
  • In beforeModel: 1. Abort transition. 2. Call verifying API by ajax. 3. If success, then transition.retry (redirect to other route otherwise). – Microfed Mar 22 '14 at 09:31