Skip to content

Trying to view info page of user who has never logged in in admin panel crashes due to unset current_sign_in_at #639

@halcy

Description

@halcy

As stated in the title, when a user makes an account and then never logs in, their current_sign_in_at date is nil, which makes the admin "edit user" page (that tries to display that as a date) break. Log attached. Suggested fix: Initialize current_sign_in_at to current date when user registers.

Feb 16 08:43:34 icosahedron bundle[29708]: [d67fddf3-eb68-4141-8911-db91548f99a2]   #033[1m#033[36mUser Load (1.1ms)#033[0m  #033[1m#033[34mSELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2#033[0m  [["id", 1], ["LIMIT", 1]]
Feb 16 08:43:34 icosahedron bundle[29708]: [d67fddf3-eb68-4141-8911-db91548f99a2]   #033[1m#033[36mAccount Load (0.7ms)#033[0m  #033[1m#033[34mSELECT  "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT $2#033[0m  [["id", 1], ["LIMIT", 1]]
Feb 16 08:43:34 icosahedron bundle[29708]: [d67fddf3-eb68-4141-8911-db91548f99a2]   #033[1m#033[36mAccount Load (2.3ms)#033[0m  #033[1m#033[34mSELECT  "accounts".* FROM "accounts" WHERE "accounts"."domain" IS NULL ORDER BY "accounts"."id" DESC LIMIT $1 OFFSET $2#033[0m  [["LIMIT", 40], ["OFFSET", 0]]
Feb 16 08:43:34 icosahedron bundle[29708]: [d67fddf3-eb68-4141-8911-db91548f99a2] method=GET path=/admin/accounts format=html controller=Admin::AccountsController action=index status=200 duration=90.36 view=68.26 db=4.00
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]   #033[1m#033[36mUser Load (1.8ms)#033[0m  #033[1m#033[34mSELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2#033[0m  [["id", 1], ["LIMIT", 1]]
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]   #033[1m#033[36mAccount Load (1.0ms)#033[0m  #033[1m#033[34mSELECT  "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT $2#033[0m  [["id", 1], ["LIMIT", 1]]
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]   #033[1m#033[36mAccount Load (1.4ms)#033[0m  #033[1m#033[34mSELECT  "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT $2#033[0m  [["id", 72], ["LIMIT", 1]]
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]   #033[1m#033[36mUser Load (0.8ms)#033[0m  #033[1m#033[34mSELECT  "users".* FROM "users" WHERE "users"."account_id" = $1 LIMIT $2#033[0m  [["account_id", 72], ["LIMIT", 1]]
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c] method=GET path=/admin/accounts/72 format=html controller=Admin::AccountsController action=show status=500 error='ActionView::Template::Error: Object must be a Date, DateTime or Time object. nil given.' duration=30.94 view=0.00 db=4.87
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c] ActionView::Template::Error (Object must be a Date, DateTime or Time object. nil given.):
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]     22:         %td= @account.user.current_sign_in_ip
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]     23:       %tr
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]     24:         %th Most recent activity
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]     25:         %td= l @account.user.current_sign_in_at
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]     26:     - else
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]     27:       %tr
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]     28:         %th Profile URL
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c]
Feb 16 08:43:50 icosahedron bundle[29708]: [3050a595-983b-4e32-ac68-c3b7d0c5b68c] app/views/admin/accounts/show.html.haml:25:in `_app_views_admin_accounts_show_html_haml__3652720127297539637_47367399992900'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions