Browse Source

it now compiles

Maxim Sokhatsky 11 years ago
parent
commit
ca24aae23e
9 changed files with 51 additions and 6 deletions
  1. 1 1
      README.md
  2. 5 1
      rebar.config
  3. 9 0
      src/avz.app.src
  4. 6 0
      src/avz_app.erl
  5. 11 0
      src/avz_sup.erl
  6. 1 0
      src/facebook.erl
  7. 10 1
      src/github.erl
  8. 4 2
      src/google.erl
  9. 4 1
      src/twitter.erl

+ 1 - 1
README.md

@@ -1,7 +1,7 @@
 AVZ Login System for N2O
 ========================
 
-Authentication methods N2O sites. Supports both JavaScript based
+Authentication methods for N2O sites. Supports both JavaScript based
 logins (like Google and Facebook) and redirect based OAuth logins (Twitter, Github)
 in a sane and simple manner. Compatible with but not limited to Nitrogen and N2O.
 

+ 5 - 1
rebar.config

@@ -1,5 +1,9 @@
 {deps_dir, ["deps"]}.
-{deps, [n2o,kvs,{erlydtl,".*",{git,"git://github.com/voxoz/erlydtl.git","HEAD"}}]}.
+{deps, [
+    {n2o,           ".*", {git, "git://github.com/5HT/n2o.git", "HEAD"}},
+    {kvs,           ".*", {git, "git://github.com/synrc/kvs.git", "HEAD"}},
+    {erlydtl,".*",{git,"git://github.com/voxoz/erlydtl.git","HEAD"}}
+]}.
 {erlydtl_opts, [
     {doc_root,   "priv"},
     {out_dir,    "ebin"},

+ 9 - 0
src/avz.app.src

@@ -0,0 +1,9 @@
+{application, avz,
+ [
+  {description, "AVZ AUTH"},
+  {vsn, "1"},
+  {registered, []},
+  {applications, [kernel, stdlib]},
+  {mod, { avz_app, []}},
+  {env, []}
+ ]}.

+ 6 - 0
src/avz_app.erl

@@ -0,0 +1,6 @@
+-module(avz_app).
+-behaviour(application).
+-export([start/2, stop/1]).
+
+start(_StartType, _StartArgs) -> avz_sup:start_link().
+stop(_State) -> ok.

+ 11 - 0
src/avz_sup.erl

@@ -0,0 +1,11 @@
+-module(avz_sup).
+-behaviour(supervisor).
+-export([start_link/0, init/1]).
+-compile(export_all).
+-include_lib ("avz/include/avz.hrl").
+
+start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+init([]) ->
+    {ok, {{one_for_one, 5, 10}, []}}.
+

+ 1 - 0
src/facebook.erl

@@ -8,6 +8,7 @@
 -define(HTTP_ADDRESS, case application:get_env(web, http_address) of {ok, A} -> A; _ -> "" end).
 -define(FB_APP_ID, case application:get_env(web, fb_id) of {ok, Id} -> Id; _-> "" end).
 
+callback() -> ok.
 event({facebook,_}) -> ok.
 api_event(fbLogin, Args, _Term)-> JSArgs = n2o_json:decode(Args), avz:login(facebook, JSArgs#struct.lst).
 

+ 10 - 1
src/github.erl

@@ -1,6 +1,7 @@
 -module(github).
 -author('Andrii Zadorozhnii').
 -include_lib("n2o/include/wf.hrl").
+-include_lib("kvs/include/users.hrl").
 -include_lib("avz/include/avz.hrl").
 -export(?API).
 
@@ -51,13 +52,21 @@ registration_data(Props, github, Ori) ->
     {Id, Ori#user{  username = binary_to_list(proplists:get_value(<<"login">>, Props)),
                     display_name = Name,
                     avatar = proplists:get_value(<<"avatar_url">>, Props),
-                    email = email_prop(Props, github_id),
+                    email = email_prop(Props, github),
                     name  = Name,
                     surname = [],
                     github_id = Id,
                     register_date = erlang:now(),
                     status = ok }}.
 
+email_prop(Props, github) ->
+        Mail = proplists:get_value(<<"email">>, Props),
+        error_logger:info_msg("Github Auth: Mail ~p Props ~p", [Mail,Props]),
+        case Mail of
+             null -> binary_to_list(proplists:get_value(<<"login">>, Props)) ++ "@github.com";
+             undefined -> binary_to_list(proplists:get_value(<<"login">>, Props)) ++ "@github.com";
+             _ -> "hacker@voxoz.com" end.
+
 login_button() -> #panel{ class=["btn-group"], body=
     #link{id=github_btn, class=[btn, "btn-large"], 
         body=[#i{class=["icon-github", "icon-large"]}, <<"Github">>], postback={github,logingithub} }}.

+ 4 - 2
src/google.erl

@@ -23,14 +23,16 @@ registration_data(Props, google, Ori)->
                    googleplus_id = Id,
                    register_date = erlang:now(),
                    sex = proplists:get_value(gender, Props),
-                   status = ok }};
+                   status = ok }}.
 
 email_prop(Props, _) -> binary_to_list(proplists:get_value(<<"email">>, Props)).
 
 login_button()-> #panel{id=plusloginbtn, class=["btn-group"], body=
     #link{class=[btn, "btn-google-plus", "btn-large"], 
-        body=[#i{class=["icon-google-plus", "icon-large"]}, <<"Google">>] }};
+        body=[#i{class=["icon-google-plus", "icon-large"]}, <<"Google">>] }}.
 
+event(_) -> ok.
+callback() -> ok.
 sdk() ->
     wf:wire(#api{name=plusLogin, tag=plus}),
     #dtl{bind_script=false, file="google_sdk", ext="dtl", folder="priv/static/js",

+ 4 - 1
src/twitter.erl

@@ -1,6 +1,7 @@
 -module(twitter).
 -author('Andrii Zadorozhnii').
 -include_lib("n2o/include/wf.hrl").
+-include_lib("avz/include/avz.hrl").
 -include_lib("kvs/include/users.hrl").
 -export(?API).
 -define(CONSUMER_KEY, case application:get_env(web, tw_consumer_key) of {ok, K} -> K;_-> "" end).
@@ -14,12 +15,14 @@ registration_data(Props, twitter, Ori)->
                     display_name = proplists:get_value(<<"screen_name">>, Props),
                     avatar = proplists:get_value(<<"profile_image_url">>, Props),
                     name = proplists:get_value(<<"name">>, Props),
-                    email = email_prop(Props,twitter_id),
+                    email = email_prop(Props,twitter),
                     surname = [],
                     twitter_id = Id,
                     register_date = erlang:now(),
                     status = ok }}.
 
+email_prop(Props, twitter) -> binary_to_list(proplists:get_value(<<"screen_name">>, Props)) ++ "@twitter.com".
+
 callback() ->
     Token = wf:q(<<"oauth_token">>),
     Verifier =wf:q(<<"oauth_verifier">>),