<commit_before>-module(cb_who_account_controller, [Req, SessionID]).
-compile(export_all).
-default_action(login).

signup('GET', []) ->
    {ok, []};

signup('POST', []) ->
    ValidationList = [
        { fun check_password_confirmation/1, "Passwords don't match" },
        { fun(Req) -> check_password_length(Req, 5) end, 
            "Password should be more than 5 characters long" }
    ],
    Errors = lists:foldl(fun({ValidationFun, ErrorMessage}, AccIn) ->
                case ValidationFun(Req) of 
                    true -> AccIn;
                    false -> [ErrorMessage|AccIn]
                end
        end, [], ValidationList),
    HashedPassword = Req:post_param("password"),
    Account = account:new(id, Req:post_param("username"), Req:post_param("email"), 
        HashedPassword),
    Resp = case {Errors, Account:save()} of 
        {[], {ok, SavedAccount}} ->
            {redirect, "/account/login"};
        {_, {ok, SavedAccount}} ->
            {ok, [{errors, Errors}, {account, Account}]};
        {_, {error, ModelErrors}} ->
            {ok, [{errors, ModelErrors ++ Errors}, {account, Account}]}
    end,
    Resp.
<commit_msg>Don't hardcode signup redirect<commit_after>-module(cb_who_account_controller, [Req, SessionID]).
-compile(export_all).
-default_action(login).

signup('GET', []) ->
    {ok, []};

signup('POST', []) ->
    ValidationList = [
        { fun check_password_confirmation/1, "Passwords don't match" },
        { fun(Req) -> check_password_length(Req, 5) end, 
            "Password should be more than 5 characters long" }
    ],
    Errors = lists:foldl(fun({ValidationFun, ErrorMessage}, AccIn) ->
                case ValidationFun(Req) of 
                    true -> AccIn;
                    false -> [ErrorMessage|AccIn]
                end
        end, [], ValidationList),
    HashedPassword = Req:post_param("password"),
    Account = account:new(id, Req:post_param("username"), Req:post_param("email"), 
        HashedPassword),
    Resp = case {Errors, Account:save()} of 
        {[], {ok, SavedAccount}} ->
            {redirect, [{controller, "account"}, {action, "login"}]};
        {_, {ok, SavedAccount}} ->
            {ok, [{errors, Errors}, {account, Account}]};
        {_, {error, ModelErrors}} ->
            {ok, [{errors, ModelErrors ++ Errors}, {account, Account}]}
    end,
    Resp.

{'fraction_non_alphanumeric': 0.16350611040876528, 'fraction_numerical': 0.0025284450063211127, 'mean_word_length': 2.486049926578561, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1360016', 'n_tokens_mistral': 738, 'n_tokens_neox': 701, 'n_words': 152}