anchor.diff:  %%%-------------------------------------------------------------------
   %%% @author evangelosp
  -%%% @copyright (C) 2014, <COMPANY>
  +%%% @copyright (C) 2014, evalonlabs
   %%% @doc
   %%%
   %%% @end
  
positive.code: -export([init/2]).
  -export([
    allowed_methods/2,
    allow_missing_post/2,
    charsets_provided/2,
    content_types_accepted/2,
    content_types_provided/2,
    delete_completed/2,
    delete_resource/2,
    expires/2,
    forbidden/2,
    generate_etag/2,
    is_authorized/2,
    is_conflict/2,
    known_methods/2,
    languages_provided/2,
    last_modified/2,
    malformed_request/2,
    moved_permanently/2,
    moved_temporarily/2,
    multiple_choices/2,
    options/2,
    previously_existed/2,
    resource_exists/2,
    service_available/2,
    uri_too_long/2,
    valid_content_headers/2,
    valid_entity_length/2,
    variances/2
  ]).
  -export([handle/2]).
  
  -record(state, {
    method, isAuthorized = true, etag,
    email, password, registred
  }).
  
  %% FLOW: ALL[0]
  init(Req, _Opts) ->
    {cowboy_rest, Req, #state}.
  
  %% FLOW: ALL[1] OR 503
  %% Return whether the service is available.
  
negative.code: known_methods(Req, State) ->
    {[<<"GET">>, <<"HEAD">>, <<"POST">>, <<"PUT">>, <<"PATCH">>, <<"DELETE">>, <<"OPTIONS">>], Req, State}.
  
  %% FLOW: ALL[4] OR 405
  %% Return the list of allowed methods.
  allowed_methods(Req, State) ->
    Method = cowboy_req:method(Req),
    NewState = State#state{method = Method},
    {[<<"POST">>, <<"OPTIONS">>], Req, NewState}.
  
  %% FLOW: ALL[6] OR 401
  %% Return whether the user is authorized to perform the action.
  is_authorized(Req, State) ->
    NewState = State#state{state = authorization},
    {true, Req, NewState}.
  
  %% FLOW: ALL[7] OR 403
  %% Return whether access to the resource is forbidden.
  forbidden(Req, State = #state{isAuthorized = IsAuthorized}) ->
    {not IsAuthorized, Req, State}.
  
  %% FLOW: ALL[10], OPTIONS[0] THEN 200
  %% Handle a request for information.
  options(Req, State) -> {ok, Req, State}.
  
  %% FLOW: ALL[15,17,19], POST[1,3,5], PUT[2], PATCH[4] THEN 201,204 OR 400
  %% Return the list of content-types the resource accepts.
  content_types_accepted(Req, State) ->
    NewState = State#state{state = types_accepted},
    {[{{<<"application">>, <<"json">>, '*'}, handle}], Req, NewState}.
  
  handle(Req, State = #state{method = <<"POST">>}) ->
    {ok, JsonBin, _} = cowboy_req:body(Req),
  
    {QsKVList} = jiffy:decode(JsonBin),
  
    {_, EmailBin} = lists:keyfind(<<"email">>, 1, QsKVList),
    {_, PasswordBin} = lists:keyfind(<<"password">>, 1, QsKVList),
  
    case EmailBin =/= undefined andalso
      PasswordBin =/= undefined of
  