lynndylanhurley / lynndylanhurley/devise_token_auth

devise.rb Initialzer not generated / not configuring mailer correctly

Open
#1,140 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
3.6k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Followed the setup tutorial https://github.com/dnasseri/rails5-api-guide.

However, when setting up mailer config, I am unable to locate the devise.rb initializer to add the following information:

```
Devise.setup do |config|
# Using rails-api, tell devise to not use ActionDispatch::Flash
# middleware b/c rails-api does not include it.
config.navigational_formats = [:json]
end
```

I created a new devise.rb file with the above content. However, when running the following curl command:

```
curl --data "email=test3@test.com&password=testpassword1&password_confirmation=testpassword1&confirm_success_url=http://localhost:3000" http://localhost:3000/auth
```

I end up with the following in my logs:

> Started POST "/auth" for 127.0.0.1 at 2018-04-10 23:35:13 +0200
> Processing by DeviseTokenAuth::RegistrationsController#create as */*
> Parameters: {"email"=>"test3@test.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "confirm_success_url"=>"http://localhost:3000"}
>  (0.2ms) BEGIN
> User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 AND "users"."provider" = $2 LIMIT $3 [["email", "test3@test.com"], ["provider", "email"], ["LIMIT", 1]]
> SQL (0.5ms) INSERT INTO "users" ("uid", "encrypted_password", "email", "tokens", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["uid", "test3@test.com"], ["encrypted_password", "$2a$11$//lH35X2BeoWxoYSlzQFLul36L8SU0DVecPglxH6GoentGqM/BA3y"], ["email", "test3@test.com"], ["tokens", "{}"], ["created_at", "2018-04-10 21:35:13.828569"], ["updated_at", "2018-04-10 21:35:13.828569"]]
>  (19.9ms) COMMIT
>  (0.3ms) BEGIN
> SQL (0.6ms) UPDATE "users" SET "tokens" = $1, "updated_at" = $2 WHERE "users"."id" = $3 [["tokens", "{\"zYT85oY4RmjKlNQODIzZoA\":{\"token\":\"$2a$10$6qPUooSqcVTjG6lQ/hiZ3e4rIrN6uPC44IE1DkbHODk47GYiwl4K2\",\"expiry\":1524605713}}"], ["updated_at", "2018-04-10 21:35:13.971799"], ["id", 3]]
>  (9.7ms) COMMIT
>  (0.3ms) BEGIN
> User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 FOR UPDATE [["id", 3], ["LIMIT", 1]]
> SQL (0.6ms) UPDATE "users" SET "tokens" = $1, "updated_at" = $2 WHERE "users"."id" = $3 [["tokens", "{\"zYT85oY4RmjKlNQODIzZoA\":{\"token\":\"$2a$10$Hb6cME0d7HtACWnypdBD0OoT/VoroGMrB6dJrGdrjnfMgXcKEZHsy\",\"expiry\":1524605713,\"last_token\":\"$2a$10$6qPUooSqcVTjG6lQ/hiZ3e4rIrN6uPC44IE1DkbHODk47GYiwl4K2\",\"updated_at\":\"2018-04-10T23:35:13.987+02:00\"}}"], ["updated_at", "2018-04-10 21:35:14.107194"], ["id", 3]]
>  (6.8ms) COMMIT
> Completed 200 OK in 535ms (Views: 0.4ms | ActiveRecord: 40.3ms)

However, I expect mailer information as outlined in the setup tutorial:

> Started POST "/auth" for ::1 at 2016-07-23 19:16:09 -0400
> Processing by DeviseTokenAuth::RegistrationsController#create as */*
> Parameters: {"email"=>"test@test.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "confirm_success_url"=>"http://localhost:3000"}
> -- snip --
> Devise::Mailer#confirmation_instructions: processed outbound mail in 170.2ms
> Sent mail to test@test.com (8.4ms)
> Date: Sat, 23 Jul 2016 19:16:10 -0400
> From: please-change-me-at-config-initializers-devise@example.com
> Reply-To: please-change-me-at-config-initializers-devise@example.com
> To: test@test.com
> Message-ID:
> Subject: Confirmation instructions
> Mime-Version: 1.0
> Content-Type: text/html;
> charset=UTF-8
> Content-Transfer-Encoding: 7bit
> client-config: default
> redirect-url: http://localhost:3000
>
>

Welcome test@test.com!


>
>

You can confirm your account email through the link below:


>
>

Confirm my account


>
> Completed 200 OK in 666ms (Views: 0.6ms | ActiveRecord: 35.4ms)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the setup tutorial linked in the issue and reproduce the registration request using the provided curl command. Compare the observed registration logs with the expected Devise::Mailer confirmation output; done means the configured registration flow produces the expected mailer activity and confirmation details.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.