From 0d0c99fd28b782c7daf02fb5cc48d3eb252e705d Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 1 Jan 2016 14:39:40 +0100 Subject: Simplify persona usage --- src/client/js/main.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'src/client/js') diff --git a/src/client/js/main.js b/src/client/js/main.js index 12593e6..5fd73ea 100644 --- a/src/client/js/main.js +++ b/src/client/js/main.js @@ -5,24 +5,16 @@ var app = Elm.fullscreen(Elm.Main, { sign: null }); -navigator.id.watch({ - loggedInUser: null, - onlogin: function(assertion) { - app.ports.sign.send({ - operation: 'SignIn', - assertion: assertion - }); - }, - onlogout: function() {} -}); - -app.ports.persona.subscribe(function(communication) { - if(communication === 'SignIn') { - navigator.id.request(); - } else if(communication === 'SignOut') { - navigator.id.logout(); - app.ports.sign.send({ - operation: 'SignOut' - }); - } +app.ports.persona.subscribe(function() { + navigator.id.watch({ + loggedInUser: null, + onlogin: function(assertion) { + app.ports.sign.send({ + operation: 'SignIn', + assertion: assertion + }); + }, + onlogout: function() {} + }); + navigator.id.request(); }); -- cgit v1.2.3