Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on recovery submission #67

Open
Lazarus404 opened this issue Dec 29, 2015 · 4 comments
Open

Error on recovery submission #67

Lazarus404 opened this issue Dec 29, 2015 · 4 comments

Comments

@Lazarus404
Copy link

Hi,

So, I've got Addict set up nicely, but I've noticed an error occurs silently when calling /recover_password:

[error] #PID<0.352.0> running Pickpro.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /recover_password
** (exit) an exception was raised:
    ** (Plug.Conn.AlreadySentError) the response was already sent
        (plug) lib/plug/conn.ex:311: Plug.Conn.put_status/2
        lib/addict/interactors/session_interactor.ex:41: Addict.SessionInteractor.password_recover/2
        lib/addict/controller.ex:95: Addict.Controller.recover_password/2
        lib/addict/controller.ex:89: Addict.Controller.action/2
        lib/addict/controller.ex:89: Addict.Controller.phoenix_controller_pipeline/2
        (pickpro) lib/phoenix/router.ex:261: Pickpro.Router.dispatch/2
        (pickpro) web/router.ex:1: Pickpro.Router.do_call/2
        (pickpro) lib/pickpro/endpoint.ex:1: Pickpro.Endpoint.phoenix_pipeline/1
        (pickpro) lib/plug/debugger.ex:92: Pickpro.Endpoint."call (overridable 3)"/2
        (pickpro) lib/phoenix/endpoint/render_errors.ex:34: Pickpro.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

I'm using Phoenix 1.1 and I've forced the Ecto version to 1.1.1, so this might be the issue.

@JoschkaSchulz
Copy link

Could it be that it's because of the plug :action that is given in the addict controller? I had a similar problem with login. Maybe it's default in phoenix now?

@Lazarus404
Copy link
Author

It seems to be those email templates, again... It would be good to have a little write up on these. Perhaps explaining where to look so you know what parameters are made available to include in the templates. I think that should be sufficient.

@Lazarus404
Copy link
Author

So, tracking down the issue; in Addict.Mailers.MailSender.convert_to_list, this is returned:

[username: "lee@domain.com", type: "client", tel: "0234567890",
 sector: "Management",
 encrypted_password: "$pbkdf2-sha512$160000$VNuu8F9Mz9DglMpcAgdJBw$fbU349xWvlsioZEExDVCYSp1TqhEVQeVn4DtY4d3BD3rnYrXCL3oxqBz5ft8iwlRKupiYFJmlBjWYpVjPIoInA",
 email: "lee@domain.com", country: "NZ"]

but, the module errors with

[error] #PID<0.428.0> running Pickpro.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /register
** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in EEx.Tokenizer.tokenize/5
        (eex) lib/eex/tokenizer.ex:27: EEx.Tokenizer.tokenize(#Function<20.50752066/0 in :erl_eval.expr/5>, 1, [trim: false], [], [])
        (eex) lib/eex/compiler.ex:16: EEx.Compiler.compile/2
        (eex) lib/eex.ex:191: EEx.eval_string/3
        lib/addict/mailers/mail_sender.ex:13: Addict.Mailers.MailSender.send_register/1

I'm gonna see if I can work out why, but any help appreciated. The template I'm using is just a string. It doesn't include any parameters whatsoever.

Thanks

@trenpixster
Copy link
Owner

@Lazarus404 can you please share the config piece at config.exs that sets the value for email_register_template and the source of what it is pointing at?

Here's my test run:

iex(1)> defmodule Foo do
...(1)> def template_register do
...(1)> "some simple string"
...(1)> end
...(1)> end
{:module, Foo,
 <<70, 79, 82, 49, 0, 0, 5, 20, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 140, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>,
 {:template_register, 0}}
iex(2)> payload = [username: "lee@domain.com", type: "client", tel: "0234567890", sector: "Management", encrypted_password: "$pbkdf2-sha512$160000$VNuu8F9Mz9DglMpcAgdJBw$fbU349xWvlsioZEExDVCYSp1TqhEVQeVn4DtY4d3BD3rnYrXCL3oxqBz5ft8iwlRKupiYFJmlBjWYpVjPIoInA", email: "lee@domain.com", country: "NZ"]
[username: "lee@domain.com", type: "client", tel: "0234567890",
 sector: "Management",
 encrypted_password: "$pbkdf2-sha512$160000$VNuu8F9Mz9DglMpcAgdJBw$fbU349xWvlsioZEExDVCYSp1TqhEVQeVn4DtY4d3BD3rnYrXCL3oxqBz5ft8iwlRKupiYFJmlBjWYpVjPIoInA",
 email: "lee@domain.com", country: "NZ"]
iex(3)> EEx.eval_string Foo.template_register, payload
"some simple string"
iex(4)>

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants