From 2be058bfd57790616a9d3282260a89dc1ccf65ab Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 11 Dec 2017 09:31:54 +0100 Subject: checkin working, auth.user populating --- public/assets/js/lib/sdk/auth.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'public/assets/js/lib/sdk/auth.js') diff --git a/public/assets/js/lib/sdk/auth.js b/public/assets/js/lib/sdk/auth.js index a5a735a..c720292 100644 --- a/public/assets/js/lib/sdk/auth.js +++ b/public/assets/js/lib/sdk/auth.js @@ -10,9 +10,8 @@ var auth = (function(){ auth.next_view = null auth.init = function(fn){ - console.log("auth init") // if we're on an authentication page, ignore the current user - if (window.location.pathname !== '/login' || window.location.pathname !== '/signup') { + if (window.location.pathname === '/login' || window.location.pathname === '/signup') { fn && fn( false ) return } @@ -67,8 +66,19 @@ var auth = (function(){ auth.logged_in = function(){ return (auth.user.id && auth.user.id !== -1 && auth.user.id !== "undefined") } - auth.checkin = function(){ - + auth.checkin = function(opt){ + $.ajax({ + method: 'put', + url: '/api/checkin', + success: function(data){ + if (data && data.user && data.user.id !== -1) { + auth.set_user(data.user) + opt.success(data.user) + return + } + opt.error() + } + }) } return auth -- cgit v1.2.3-70-g09d2