Added welcome and profile actions to the my controller
This commit is contained in:
parent
8e4dd058b6
commit
020a864736
12 changed files with 125 additions and 19 deletions
|
|
@ -113,4 +113,9 @@ class Screenshot < ApplicationRecord
|
|||
def self.uploaded_by(token)
|
||||
self.where(approved: false, uploaderhash: token)
|
||||
end
|
||||
|
||||
# Check whether the user has administrative permissions
|
||||
def can_admin?
|
||||
self.admin == 1
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
class User < ApplicationRecord
|
||||
has_many :screenshots, :inverse_of=>:user
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
|
|
@ -18,6 +19,25 @@ class User < ApplicationRecord
|
|||
:github
|
||||
]
|
||||
|
||||
# Return a human-friendly string describing the user's SSO provider
|
||||
def pretty_provider
|
||||
case self.provider
|
||||
when 'launchpad'
|
||||
'Ubuntu One/Launchpad'
|
||||
when 'stackexchange'
|
||||
'StackExchange'
|
||||
when 'google_oauth2'
|
||||
'Google'
|
||||
when 'amazon'
|
||||
'Amazon'
|
||||
when 'github'
|
||||
'GitHub'
|
||||
end
|
||||
end
|
||||
|
||||
def is_admin?
|
||||
self.admin == 1
|
||||
end
|
||||
|
||||
def self.from_omniauth(auth)
|
||||
where(provider: auth.provider, email: auth.info.email).first_or_create do |user|
|
||||
|
|
@ -29,5 +49,4 @@ class User < ApplicationRecord
|
|||
user.password = Devise.friendly_token[0,20]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue