私のタイトルがおそらく少し誤解を招くものだったかどうかはわかりません。しかし、これが私が本当に助けを必要としていることです。
私はこのURLを取得しています:
$.get("/fb/login/"+fbEmail, function(data){
console.log(data);
});
これが私のルートです:
GET /fb/login/:email presentation.controllers.Auth.authenticateSocialNetwork(email:String)
そして、これが私の行動です:
def authenticateSocialNetwork(email:String) = Action {
if(!editorRepo.getEditorByEmail(email).isEmpty){
Redirect(routes.Profile.editorProfile).withSession(Security.username -> email)
} else {
Redirect(routes.Profile.initiatorProfile).withSession(Security.username -> email)
}
}
これからの私の期待は、私のアクションが呼び出され、その中身が発火することです。つまり、リダイレクトします。
しかし、実際に起こることは、それほど非論理的ではありませんが、$。get呼び出しがリダイレクトで応答を受け取ることです。
javascriptに応答を送信せずに、実際にaction-methodを呼び出すにはどうすればよいですか?
これがjavascriptでの私の関数です。このスニペットを投稿して、上記のコメントのディスカッションでより明確にします。
function addClickToLoginButtons(){
$("#loginWithFb").click(function(){
FB.login(function(response){
if(response.authResponse){
FB.api('/me', function(response){
var fbEmail = response.email;
$.get("/fb/isRegisteredAtNetwork/"+fbEmail+"/facebook", function(data){
if(data == "true"){
if(confirm("Do you want to log with facebook-account "+fbEmail+"?")){
$.get("/fb/login/"+fbEmail, function(data){ *//HERE'S WHERE I WOULD WANT TO CALL MY METHOD IN SCALA*
console.log(data);
});
} else {
console.log("try again with a different facebook-account");
} //end confirm else
} else {
console.log("Logged in not in database");
}//end get else
});
});
} else {
console.log("permission not granted");
} // end authResponse else
}, {scope: 'email'});
});
}