---
# System prepended metadata

title: お客様作成→パスワード再設定時のレコードの挙動
tags: [調査]

---

# お客様作成→パスワード再設定時のレコードの挙動




###### tags: `調査`

## 再設定前のレコード

![](https://i.imgur.com/XXBApdm.png)

```sql= 
id |      email      | encrypted_password | reset_password_token | reset_password_sent_at | remember_created_at | confirmation_token | confirmed_at | confirmation_sent_at | unconfirmed_email |         created_at         |         updated_at         | provider |       uid       | allow_password_change | name | tokens | dec_password |   type   | plan_term_month | plan_begins_on | plan_id |           reset_token            | company_name | first_name | first_name_kana | last_name | last_name_kana
----+-----------------+--------------------+----------------------+------------------------+---------------------+--------------------+--------------+----------------------+-------------------+----------------------------+----------------------------+----------+-----------------+-----------------------+------+--------+--------------+----------+-----------------+----------------+---------+----------------------------------+--------------+------------+-----------------+-----------+----------------
 24 | test@gasdga.com |                    |                      |                        |                     |                    |              |                      |                   | 2020-12-04 00:30:41.889301 | 2020-12-04 00:30:41.897076 | email    | test@gasdga.com | f                     | 坂本 |        |              | Customer |                 |                |       2 | 24457bcb1539ff6ba6a81e7c60e69763 | test         |            |                 |           |
```

### 再設定後のレコード

```sql=
 id |      email      |                      encrypted_password                      | reset_password_token | reset_password_sent_at | remember_created_at | confirmation_token | confirmed_at | confirmation_sent_at | unconfirmed_email |         created_at         |         updated_at         | provider |       uid       | allow_password_change | name |                                                                                    tokens                                                                                    | dec_password |   type   | plan_term_month | plan_begins_on | plan_id | reset_token | company_name | first_name | first_name_kana | last_name | last_name_kana
----+-----------------+--------------------------------------------------------------+----------------------+------------------------+---------------------+--------------------+--------------+----------------------+-------------------+----------------------------+----------------------------+----------+-----------------+-----------------------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+----------+-----------------+----------------+---------+-------------+--------------+------------+-----------------+-----------+----------------
 24 | test@gasdga.com | $2a$11$a27yThnX0XpxQFxQx/bCR.OERgteVBUG1At0UL9//gR4eBFD0gxZa |                      |                        |                     |                    |              |                      |                   | 2020-12-04 00:30:41.889301 | 2020-12-04 00:50:17.631329 | email    | test@gasdga.com | f                     | 坂本 | "{\"dU61Q3C8QF6lGMXODTs19A\":{\"token\":\"$2a$10$BTr5ccXlBZT7eR6kSGvZKuHUv90f/wNWE0Ej7KKMwhYjro4Pv7ezi\",\"expiry\":1608252616,\"updated_at\":\"2020-12-04 00:50:17 UTC\"}}" |              | Customer |                 |                |       2 |             | test         |            |                 |           |
```

### メモ

変わること

1. encrypted_password、tokensが作成される
2. reset_tokenが削除される

reset_tokenを使用して、新規トークンと暗号化されたパスワードが再設定されるぽい
そして再設定を２回目されたら困るのでreset_tokenを消すみたい。