I have a link in an email for resetting a user password. This link takes the user to a password-reset template with a parameter containing the reset token:
http://localhost:8000/password-reset?token=asldfasjdfalsdf
I need to get the token in the PasswordResetController on transition from the email link. I have tried using queryParams but haven't had any luck. I tried the code below and also using window.location.href but the problem is getting the param on transition to the page before the controller is loaded. Thank you in advance for the help.
App.NewPasswordController = Ember.Controller.extend
queryParams: ['token']
token: null
actions:
submit: ->
token = @get 'token' # Here lies the culprit.
password = @get 'password'
passwordConfirmation = @get 'passwordConfirmation'
data = JSON.stringify password: password, password_confirmation: passwordConfirmation, token: token
ic.ajax.request(type: 'PUT', url: 'api/v1/password_resets/update', data: data).then (result)=>
console.log result
if result.status == 'ok'
console.log 'ok'
# Log user in
else
console.log 'Error: ForgotPasswordController#submit'
SOLUTION
I had tried query params before but just saw on the docs today that you have to be using one of the newer beta versions of Ember for it to work. I switched to 1.7.0-beta.4 and query params is now working great.
App.NewPasswordController = Ember.Controller.extend
queryParams: ['token']
token: null
actions:
submit: ->
token = @get 'token'