2017-07-12 3 views
1

ログイン後にユーザーダッシュボードにリダイレクトしたいのですが、どうすればいいですか?現在、私は、登録ページとログインページを持っていますが、任意のファイルを必要とする、背中ログインと登録は、私はそれがダッシュボードに行きたいホームページにそれをログインした後、私はここでログイン後のダッシュボードへのリダイレクト[EMBER.JS]


UPDATE投稿:

コントローラ/ application.js

import Ember from 'ember'; 


export default Ember.Controller.extend({ 
session: Ember.inject.service('session'), 

    actions: { 
    invalidateSession() { 
    this.get('session').invalidate(); 
} 
} 
}); 

コントローラ/ login.js

import Ember from 'ember'; 

export default Ember.Controller.extend({ 
    session: Ember.inject.service('session'), 

    actions: { 
    authenticate() { 
    let { identification, password } = 
this.getProperties('identification', 'password'); 
    this.get('session').authenticate('authenticator:oauth2', 
identification, password).catch((reason) => { 
    this.set('errorMessage', reason.error || reason); 
    }); 
} 
} 
}); 

ルートは/あなたがバックエンドに渡す/ログインを送るコードで

import Ember from 'ember'; 
import ApplicationRouteMixin from 'ember-simple- 
auth/mixins/application-route-mixin'; 

export default Ember.Route.extend(ApplicationRouteMixin, { 
actions: { 
    invalidateSession() { 
    this.get('session').invalidate(); 
} 
} 

}); 

ルート/ login.js

import Ember from 'ember'; 

export default Ember.Route.extend({ 
}); 

答えて

0

をapplication.jsは、使用することができますリダイレクトするための成功のコールバックを約束してください:

あなたのルートのどこかにアプリケーションルートまたはログインルート):

actions: { 
    checkAuth(email, password) { 
    let _this = this; 
    // Ajax call or service call 
    .....authenticate(email, password).then(function(data) { 
     // set current user 
     // do whatever you want 
     _this.transitionTo("dashboard"); // redirect to the dashboard route 
    }); 
    } 
} 
+0

私はアプリケーションのルートに入れた後、ルートのログインではなく、両方が影響を与えなかった。.. – Techtique

+0

[ember twiddle](https://ember-twiddle.com/)でユーザーを認証する部分を分かち合うことができますか? – kubz

+0

コードの一部をコピーし、 – Techtique

関連する問題