allow all Salsa users to be moderators
This commit is contained in:
parent
b25ef5882f
commit
8a13c92028
1 changed files with 15 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class User < ApplicationRecord
|
||||
has_many :screenshots, inverse_of: :user
|
||||
|
||||
|
|
@ -63,8 +64,10 @@ class User < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
# Return from the Salsa SSO process
|
||||
def self.from_omniauth(auth)
|
||||
where(provider: auth.provider, email: auth.info.email).first_or_create do |user|
|
||||
# Finds or creates a user based on the provider and email from the authentication data
|
||||
this_user = where(provider: auth.provider, email: auth.info.email).first_or_create do |user|
|
||||
user.provider = auth.provider
|
||||
user.uid = auth.uid
|
||||
user.email = auth.info.email
|
||||
|
|
@ -73,8 +76,18 @@ class User < ApplicationRecord
|
|||
user.password = Devise.friendly_token[0, 20]
|
||||
|
||||
# Users coming through salsa.debian.net/OpenID-Connect will get moderator role
|
||||
user.moderator_role = true if user.email.end_with?('@debian.org') && user.provider == 'salsa'
|
||||
# TODO: allow DMs who do not have an @debian.org address
|
||||
#user.moderator_role = true if user.email.end_with?('@debian.org') && user.provider == 'salsa'
|
||||
user.moderator_role = true if user.provider == 'salsa'
|
||||
end
|
||||
|
||||
# Get the groups of the user from the OAuth server
|
||||
# this_user.groups = auth.extra.raw_info.groups if auth.extra.raw_info.respond_to?(:groups)
|
||||
#
|
||||
# # Log the extra information from the OAuth server
|
||||
# Rails.logger.info "OAuth extra info: #{auth.extra.raw_info.inspect}"
|
||||
#
|
||||
# this_user
|
||||
end
|
||||
|
||||
# Seamlessly create a user account for the current visitor.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue