Amber: Amber auth edit user don't work w/ method patch in form

Created on 29 Dec 2018  Â·  7Comments  Â·  Source: amberframework/amber

Description

Update user profile of amber auth don't work.

Steps to Reproduce

  1. Create a new amber project with sqlite
  2. Create amber auth using
    amber g auth User
  3. Create and migrate the database.
  4. I use both seed the db or register a new user.

Expected behavior:
Expect to edit the user email

Actual behavior:
Doesn't edited the user

Reproduces how often:
Always

Versions

I am using latest versions of both Crystal and Amberframework

Additional Information

when i change the form method in the src/views/user/edit.ecr from patch to post it works. Put and patch don't work.

P.S It would be nice to be able to edit password too.

Thank you

bug

All 7 comments

I can't replicate this following your instructions - I'm able to edit my email every time. Have you customised anything at all, or do you have an example repository?

Granted there is no functionality to change password at the moment - but there doesn't appear to be any forgotten password functionality either. Perhaps we could get away with just implementing that?

I created a new project and test it twice. I will give another try right now and if the problem remains I will push it to an example repository.

I think auth and oauth functionality will take the framework to the next level. Also it will drive to create admin panel in top of it.

Update: @dwightwatson i try it for a third time and the problem still remains. I created a repo here

@Willyboar looks like it may be related to using ecr templates.

@drujensen i tried it w/ slang and it works. So you are right, it is probably ecr .

Looks like it's because slang uses the form helper but ECR just outputs a form tag with method="patch", which a browser will do nothing about.

== form(action: "/profile", method: :patch) do

vs

<form action="/profile" method="patch">

I'm not actually sure how to fix it because my ECR isn't that great. I've tried this which I thought would do the job, but it fails to compile. What's the appropriate way to pass a block and output the whole thing in ECR?

<%= form(action: "/profile", method: :patch) do %>
  <%= csrf_tag %>
  <div class="form-group">
    <input class="form-control" type="email" name="email" placeholder="Email" value="<%= user.email %>" />
  </div>
  <%= submit("Update", class: "btn btn-primary btn-sm") %>
  <%= link_to("profile", "/profile", class: "btn btn-light btn-sm") %>
<%- end %>

As I said before it works if you change patch to post. But I don't know if it is correct. ☺

@dwightwatson unfortunately, blocks are not supported in ecr yet.

@Willyboar post will create a new user, not update one. We will need to add a hidden field _method with the value of patch for this to work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eliasjpr picture eliasjpr  Â·  6Comments

faustinoaq picture faustinoaq  Â·  4Comments

faustinoaq picture faustinoaq  Â·  5Comments

faustinoaq picture faustinoaq  Â·  6Comments

Meldanor picture Meldanor  Â·  4Comments