1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

Fix profile page on fresh install (#684)

This commit is contained in:
Razvan Marescu 2024-04-27 05:59:02 -07:00 committed by GitHub
parent e7fe1b5a4b
commit 93953499a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 50 additions and 11 deletions

View file

@ -7,12 +7,22 @@ class User < ApplicationRecord
validates :email, presence: true, uniqueness: true
normalizes :email, with: ->(email) { email.strip.downcase }
normalizes :first_name, :last_name, with: ->(value) { value.strip.presence }
enum :role, { member: "member", admin: "admin" }, validate: true
generates_token_for :password_reset, expires_in: 15.minutes do
password_salt&.last(10)
end
def display_name
[ first_name, last_name ].compact.join(" ").presence || email
end
def initial
(display_name&.first || email.first).upcase
end
def acknowledge_upgrade_prompt(commit_sha)
update!(last_prompted_upgrade_commit_sha: commit_sha)
end