[ClojureScript] Authentication for AJAX calls

2014-08-15 Thread Jonathon McKitrick
I've applied Friend to my page authentication with great success, but I'm not 
sure how to do the same with my AJAX API calls.  Obviously, you don't want to 
pass cleartext credentials around.

What have you all used in this case?

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Re: Authentication for AJAX calls

2014-08-15 Thread Tobias Quinn
I've used Friend for a single page app. It serves the main page to anyone and 
has a route that can issue a json web token (jwt) using http basic 
authentication. I used clj-jwt to generate the token.

Then, the api routes required by the app are authenticated using the jwt in the 
authorization header.

It involved writing a friend workflow for the jwt which is similar to the 
http-basic workflow.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: help ! modal control from clojurescript does not work

2014-08-15 Thread Makoto H.
Thank you for testing my code.
I have checked my code, however it looks no paren problem.
I begin to suspect my environment. I am using react 1.11.1 and 
om 0.7.1. I also run to check my code using js stepping debugger but
it takes time.

Thanks,
Makoto

 I just tried out your gist and it worked fine for me. The error you're 
 getting is when a render or render-state returns more than one component. The 
 code looked ok, so maybe when you were editing, you accidentally added or 
 removed a critical closing paren.
 
 
 
 But what you had in your gist was ok, at least for me.
 
 
 
 On Thursday, August 14, 2014 6:07:42 PM UTC-7, Makoto H. wrote:
 
  I'm trying to run Jason's code but I cannot run it work.
 
  I received the following error when I run (modal-ui). 
 
  
 
  #function modal_ui(){return 
  om.core.root.call(null,test.modal.wrapper,test.modal.app_state,new 
  cljs.core.PersistentArrayMap(null, 1, [new 
  cljs.core.Keyword(null,target,target,253001721),document.getElementById(app)],
   null));
 
  
 
  }
 
  Error evaluating: (modal-ui) :as test.modal.modal_ui.call(null);\n
 
  #Error: Invariant Violation: ReactCompositeComponent.render(): A valid 
  ReactComponent must be returned. You may have returned null, undefined, an 
  array, or some other invalid object.
 
  
 
  Error: Invariant Violation: ReactCompositeComponent.render(): A valid 
  ReactComponent must be returned. You may have returned null, undefined, an 
  array, or some other invalid object.
 
      at invariant (http://localhost:8080/js-lib/react.js:15915:19)
 
  
 
      at null.anonymous (http://localhost:8080/js-lib/react.js:6034:41)
 
      at null._renderValidatedComponent 
  (http://localhost:8080/js-lib/react.js:11403:21)
 
  
 
      at null.anonymous (http://localhost:8080/js-lib/react.js:5582:14)
 
      at null.mountComponent (http://localhost:8080/js-lib/react.js:11403:21)
 
  
 
      at ReactMultiChild.Mixin.mountChildren 
  (http://localhost:8080/js-lib/react.js:10913:42)
 
      at ReactDOMComponent.Mixin._createContentMarkup 
  (http://localhost:8080/js-lib/react.js:6812:32)
 
  
 
      at null.anonymous (http://localhost:8080/js-lib/react.js:6734:14)
 
      at null.mountComponent (http://localhost:8080/js-lib/react.js:11403:21)
 
  
 
      at null.anonymous (http://localhost:8080/js-lib/react.js:5587:44)
 
  
 
  
 
  What is a problem in my code do you think ?
 
  
 
  
 
  https://gist.github.com/tokomakoma123/3e33299cc7dd7ecf63ad
 
  
 
  
 
  
 
  Thanks,
 
  Makoto
 
  
 
  
 
  
 
  
 
  2014-08-14 21:11 GMT+09:00 Daniel Kersten dker...@gmail.com:
 
  
 
  
 
  I tried the bootstrap-cljs modal yesterday and it works pretty well for me. 
  I'd say its definitely worth a look.
 
  
 
  
 
  
 
  
 
  
 
  
 
  On 14 August 2014 07:44, Makoto H. tokoma...@gmail.com wrote:
 
  
 
  
 
  It looks cool ! I will try to run your code.
 
  
 
  
 
  
 
  
 
  
 
   Don't know if this'll help you, but I had a similar issue and took a stab 
   at translating the bootstrap modal into an om component. It's a bit 
   hacky, but here it is:
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
   (ns om-pages.components.modal
 
  
 
  
 
  
 
     (:require-macros [cljs.core.async.macros :refer [go]])
 
  
 
  
 
  
 
     (:require [goog.dom :as gdom]
 
  
 
  
 
  
 
               [om.core :as om :include-macros true]
 
  
 
  
 
  
 
               [om.dom :as dom :include-macros true]
 
  
 
  
 
  
 
               [cljs.core.async :refer [chan timeout put! !]]))
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
   (def modal-opts-chan (chan))
 
  
 
  
 
  
 
   (def modal-close-chan (chan))
 
  
 
  
 
  
 
   (def fade-time 160)
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
   (defn set-modal [modal-opts]
 
  
 
  
 
  
 
     (put! modal-opts-chan modal-opts))
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
   (defn close-modal []
 
  
 
  
 
  
 
     (put! modal-close-chan true))
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
   (defn option-button [{:keys [text style action]}]
 
  
 
  
 
  
 
     (let [className (str btn btn- (or style default))]
 
  
 
  
 
  
 
       (dom/button #js {:type button :className className :onClick action} 
  text)))
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
   (defn modal [cursor owner]
 
  
 
  
 
  
 
     (reify
 
  
 
  
 
  
 
       om/IInitState
 
  
 
  
 
  
 
       (init-state [_]
 
  
 
  
 
  
 
         {:modal-opts nil})
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
       om/IWillMount
 
  
 
  
 
  
 
       (will-mount [_]
 
  
 
  
 
  
 
         (go (loop []
 
  
 
  
 
  
 
           (om/set-state! owner :modal {:opts (! modal-opts-chan) :state 
  :init})
 
  
 
  
 
  
 
           (! (timeout 50))
 
  
 
  
 
  
 
           (om/set-state! owner [:modal :state] :in)
 
  
 
  
 
  
 
           (! modal-close-chan)
 
  
 
  
 
  
 
           (om/set-state! owner [:modal :state]  :out)
 
  
 
  
 
  
 
           (! (timeout fade-time))
 
  
 
  
 
  
 
           (om/set-state! owner :modal {:opts nil :state :clear})