Browse Source

todo mv work with session to n2o (n4u)

221V 1 year ago
parent
commit
34abd0fb04
2 changed files with 15 additions and 14 deletions
  1. 0 11
      src/nitro.erl
  2. 15 3
      src/nitro_n2o.erl

+ 0 - 11
src/nitro.erl

@@ -10,7 +10,6 @@
   pickle/1, depickle/1, unique_integer/0, temp_id/0,
   to_list/1, to_atom/1, to_binary/1, to_integer/1,
   join/2, replace/3, indexof/2, indexof/3, append/3, os_env/1, os_env/2,
-  prolongate/0, authenticate/2,
   render/1, wire/1, hex/1, unhex/1, js_escape/1, js_escape/2,
   html_encode/1, html_encode/2, url_encode/1, url_decode/1,
   update/2, insert_top/2, insert_top/3, insert_bottom/2, insert_bottom/3,
@@ -140,16 +139,6 @@ pickle(Data) -> ?PICKLER:pickle(Data).
 depickle(SerializedData) -> ?PICKLER:depickle(SerializedData).
 
 
-prolongate() ->  %% todo mv this from nitro
-  case application:get_env(n2o, session) of
-    {ok, M} -> M:prolongate();
-    undefined -> false
-  end.
-
-authenticate(I, Auth) -> %% todo mv this from nitro
-  (application:get_env(n2o, session, n2o_session)):authenticate(I, Auth).
-
-
 render(X) -> wf_render:render(X).
 
 

+ 15 - 3
src/nitro_n2o.erl

@@ -21,7 +21,7 @@ info({text, <<"N2O,", Auth/binary>>}, Req, State) ->
   info(#init{token = Auth}, Req, State);
 
 info(#init{token = Auth}, Req, State) ->
-  {'Token', Token} = nitro:authenticate([], Auth),
+  {'Token', Token} = authenticate([], Auth),
   Sid = case nitro:depickle(Token) of
     {{S, _}, _} -> S;
     X -> X
@@ -73,14 +73,14 @@ render_actions(Actions) ->
 
 html_events(#pickle{source = Source, pickled = Pickled, args = Linked}, State = #cx{token = Token}) ->
   Ev  = nitro:depickle(Pickled),
-  L   = nitro:prolongate(),
+  L   = prolongate(),
   Res = case Ev of
     #ev{} when L =:= false ->
       render_ev(Ev, Source, Linked, State),
       <<>>;
     #ev{} ->
       render_ev(Ev, Source, Linked, State),
-      nitro:authenticate([], Token);
+      authenticate([], Token);
     _CustomEnvelop ->
       %?LOG_ERROR("EV expected: ~p~n",[CustomEnvelop]),
       {error, "EV expected"}
@@ -88,6 +88,18 @@ html_events(#pickle{source = Source, pickled = Pickled, args = Linked}, State =
   io(Res).
 
 
+%% todo move work with session to n2o (n4u)
+prolongate() ->  %% todo mv this from nitro
+  case application:get_env(n2o, session) of
+    {ok, M} -> M:prolongate();
+    undefined -> false
+  end.
+
+
+authenticate(I, Auth) -> %% todo mv this from nitro
+  (application:get_env(n2o, session, n2o_session)):authenticate(I, Auth).
+
+
 %% calling user code in exception-safe manner
 
 -ifdef(OTP_RELEASE).