mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:31:10 +08:00
FEATURE: further restrict downloading of backups
- send email to logged in admin when they press the "download" button - show pop-up that email was sent - create email template - require a valid token to download backup
This commit is contained in:
28
lib/email_backup_token.rb
Normal file
28
lib/email_backup_token.rb
Normal file
@ -0,0 +1,28 @@
|
||||
class EmailBackupToken
|
||||
|
||||
def self.key(user_id)
|
||||
"email-backup-token:#{user_id}"
|
||||
end
|
||||
|
||||
def self.generate
|
||||
SecureRandom.hex
|
||||
end
|
||||
|
||||
def self.set(user_id)
|
||||
token = self.generate
|
||||
$redis.setex self.key(user_id), 1.day.to_i, token
|
||||
token
|
||||
end
|
||||
|
||||
def self.get(user_id)
|
||||
$redis.get self.key(user_id)
|
||||
end
|
||||
|
||||
def self.del(user_id)
|
||||
$redis.del self.key(user_id)
|
||||
end
|
||||
|
||||
def self.compare(user_id, token)
|
||||
token == self.get(user_id)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user