email.erl 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. -module(email).
  2. -author('Andrii Zadorozhnii').
  3. -include_lib("avz/include/avz.hrl").
  4. -include_lib("nitro/include/nitro.hrl").
  5. -include_lib("n2o/include/wf.hrl").
  6. -include_lib("kvs/include/user.hrl").
  7. -compile(export_all).
  8. -export(?API).
  9. registration_data(Props, email, Ori)->
  10. Email = email_prop(Props, email),
  11. Ori#user{ display_name = proplists:get_value(<<"display_name">>, Props, Email),
  12. email = Email,
  13. names = proplists:get_value(<<"first_name">>, Props,[]),
  14. surnames = proplists:get_value(<<"last_name">>, Props,[]),
  15. register_date = os:timestamp(),
  16. tokens = avz:update({email,Email},Ori#user.tokens),
  17. status = proplists:get_value(<<"status">>, Props, ok),
  18. type = proplists:get_value(<<"type">>, Props,[]),
  19. password = avz:sha(proplists:get_value(<<"password">>,Props))}.
  20. index(K) -> wf:to_binary(K).
  21. email_prop(Props, _) -> proplists:get_value(<<"email">>, Props).
  22. login_button() -> #button{id=login, body= <<"Sign in">>, postback={email, loginemail}, source=[user,pass]}.
  23. event({email,loginemail}) -> avz:login(email, [{<<"email">>, wf:q(user)}, {<<"password">>, wf:q(pass)}]);
  24. event(_) -> ok.
  25. api_event(_,_,_) -> ok.
  26. callback() -> ok.
  27. sdk() -> [].