I'm attempting to allow multiple oauth providers using ember-cli, ember-simple-auth, torii and devise on my rails backend. Everything seems to work, but the modal never closes and the session in the client is never updated.
I am able to click on the link in the page to sign into Google(for example), sign in, and view in the rails console where the token was received from the client and passed to the server. At this point the modal redirects to the proper redirect and the modal html is updated with the json response from the server, including the access_token that should be updating the session.
My issue is that after displaying the json response, the modal never closes, and the session isn't updated. If I close the modal, the originating app's console displays this error.
Included below are my lib versions and the relevant bits of my application code. Any help would be greatly appreciated.
DEBUG: Ember : 1.13.3
DEBUG: Ember Data : 1.13.5
DEBUG: jQuery : 2.1.4
DEBUG: Ember Simple Auth : 0.8.0
DEBUG: Ember Simple Auth Torii : 0.8.0
Server:
class LoginProfiles::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def google_oauth2
login_profile = LoginProfile.find_or_create_by_google_oauth2(request.env['omniauth.auth'])
render json: { access_token: login_profile.authentication_token, login_profile_id: login_profile.id }
end
def facebook
login_profile = LoginProfile.find_or_create_by_facebook_oauth2(request.env['omniauth.auth'])
render json: { user_token: login_profile.authentication_token, login_profile_id: login_profile.id }
end
end
Client:
routes/application.coffee
`import Ember from 'ember'`
`import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin'`
ApplicationRoute = Ember.Route.extend ApplicationRouteMixin,
actions:
authenticateWithFacebook: ->
@get('session').authenticate('simple-auth-authenticator:torii', 'facebook-oauth2')
authenticateWithGooglePlus: ->
@get('session').authenticate('simple-auth-authenticator:torii', 'google-oauth2')
`export default ApplicationRoute`
templates/application.hbs
<p>
Sign in with
<a {{action "authenticateWithGooglePlus"}}>Google</a>
or
<a {{action "authenticateWithFacebook"}}>Facebook</a>
or
{{#link-to 'register' id="register"}}register a new account.{{/link-to}}
</p>
bower.json
{
"name": "brand-management-client",
"dependencies": {
"ember": "1.13.3",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-data": "1.13.5",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5",
"ember-qunit": "0.4.1",
"ember-qunit-notifications": "0.0.7",
"ember-resolver": "~0.1.18",
"jquery": "^2.1.4",
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.17.1",
"foundation": "~5.5.0",
"ember-simple-auth": "0.8.0"
}
}
package.json
{
"name": "brand-management-client",
"version": "0.0.0",
"description": "Small description for brand-management-client goes here",
"private": true,
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"start": "ember server",
"build": "ember build",
"test": "ember test"
},
"repository": "",
"engines": {
"node": ">= 0.10.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.0.2",
"broccoli-clean-css": "1.0.0",
"ember-cli": "1.13.1",
"ember-cli-app-version": "0.4.0",
"ember-cli-babel": "^5.0.0",
"ember-cli-coffeescript": "0.11.0",
"ember-cli-dependency-checker": "^1.0.0",
"ember-cli-foundation-sass": "1.1.1",
"ember-cli-htmlbars": "0.7.9",
"ember-cli-htmlbars-inline-precompile": "^0.1.1",
"ember-cli-ic-ajax": "^0.2.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.3.15",
"ember-cli-release": "0.2.3",
"ember-cli-sass": "3.1.0",
"ember-cli-simple-auth": "0.8.0",
"ember-cli-simple-auth-torii": "0.8.0",
"ember-cli-uglify": "^1.0.1",
"ember-data": "1.13.5",
"ember-disable-proxy-controllers": "^1.0.0",
"ember-export-application-global": "^1.0.2",
"torii": "^0.5.1"
}
}
Aucun commentaire:
Enregistrer un commentaire