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:
parent
e7fe1b5a4b
commit
93953499a6
4 changed files with 50 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue