diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-11 09:31:54 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-11 09:31:54 +0100 |
| commit | 2be058bfd57790616a9d3282260a89dc1ccf65ab (patch) | |
| tree | 59c270d2bdbafce29c272f4f250797105dd1e51b | |
| parent | 3ba37616c95e22442c17ce884cb2145808f1d917 (diff) | |
checkin working, auth.user populating
| -rw-r--r-- | public/assets/js/lib/sdk/auth.js | 18 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/comments.js | 4 |
2 files changed, 17 insertions, 5 deletions
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 diff --git a/public/assets/js/lib/views/details/comments.js b/public/assets/js/lib/views/details/comments.js index 5d99138..202ae72 100644 --- a/public/assets/js/lib/views/details/comments.js +++ b/public/assets/js/lib/views/details/comments.js @@ -27,6 +27,9 @@ var CommentsView = FormView.extend({ .replace(/{{date}}/g, datetime[0]) .replace(/{{time}}/g, datetime[1]) var $t = $(t) + if (auth.user.username !== comment.username) { + $t.find(".edit-links").remove() + } return $t }, @@ -37,7 +40,6 @@ var CommentsView = FormView.extend({ appendComment: function(comment){ var $el = this.parse(comment) - console.log($el) $el.insertBefore(this.$formRow) }, |
