mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
Add rubocop to our build. (#5004)
This commit is contained in:
parent
ff4e295c4f
commit
5012d46cbd
871 changed files with 5480 additions and 6056 deletions
|
@ -12,12 +12,12 @@ class Auth::CurrentUserProvider
|
|||
end
|
||||
|
||||
# log on a user and set cookies and session etc.
|
||||
def log_on_user(user,session,cookies)
|
||||
def log_on_user(user, session, cookies)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
# optional interface to be called to refresh cookies etc if needed
|
||||
def refresh_session(user,session,cookies)
|
||||
def refresh_session(user, session, cookies)
|
||||
end
|
||||
|
||||
# api has special rights return true if api was detected
|
||||
|
@ -35,7 +35,6 @@ class Auth::CurrentUserProvider
|
|||
raise NotImplementedError
|
||||
end
|
||||
|
||||
|
||||
def log_off_user(session, cookies)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ class Auth::DefaultCurrentUserProvider
|
|||
current_user = nil
|
||||
|
||||
if auth_token && auth_token.length == 32
|
||||
limiter = RateLimiter.new(nil, "cookie_auth_#{request.ip}", COOKIE_ATTEMPTS_PER_MIN ,60)
|
||||
limiter = RateLimiter.new(nil, "cookie_auth_#{request.ip}", COOKIE_ATTEMPTS_PER_MIN , 60)
|
||||
|
||||
if limiter.can_perform?
|
||||
@user_token = UserAuthToken.lookup(auth_token,
|
||||
|
@ -127,8 +127,8 @@ class Auth::DefaultCurrentUserProvider
|
|||
|
||||
if !@user_token.legacy && needs_rotation
|
||||
if @user_token.rotate!(user_agent: @env['HTTP_USER_AGENT'],
|
||||
client_ip: @request.ip,
|
||||
path: @env['REQUEST_PATH'])
|
||||
client_ip: @request.ip,
|
||||
path: @env['REQUEST_PATH'])
|
||||
cookies[TOKEN_COOKIE] = cookie_hash(@user_token.unhashed_auth_token)
|
||||
end
|
||||
elsif @user_token.legacy
|
||||
|
@ -200,7 +200,6 @@ class Auth::DefaultCurrentUserProvider
|
|||
cookies.delete(TOKEN_COOKIE)
|
||||
end
|
||||
|
||||
|
||||
# api has special rights return true if api was detected
|
||||
def is_api?
|
||||
current_user
|
||||
|
|
|
@ -52,8 +52,8 @@ class Auth::FacebookAuthenticator < Auth::Authenticator
|
|||
|
||||
def register_middleware(omniauth)
|
||||
omniauth.provider :facebook,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
setup: lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:client_id] = SiteSetting.facebook_app_id
|
||||
strategy.options[:client_secret] = SiteSetting.facebook_app_secret
|
||||
strategy.options[:info_fields] = 'gender,email,name,about,first_name,link,last_name,website,location'
|
||||
|
@ -61,7 +61,7 @@ class Auth::FacebookAuthenticator < Auth::Authenticator
|
|||
strategy.options[:scope] = 'email,user_about_me,user_location,user_website'
|
||||
end
|
||||
},
|
||||
:scope => "email"
|
||||
scope: "email"
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -47,10 +47,8 @@ class Auth::GithubAuthenticator < Auth::Authenticator
|
|||
# Potentially use *any* of the emails from GitHub to find a match or
|
||||
# register a new user, with preference given to the primary email.
|
||||
all_emails = Array.new(auth_token[:extra][:all_emails])
|
||||
all_emails.unshift({
|
||||
:email => data[:email],
|
||||
:verified => !!data[:email_verified]
|
||||
})
|
||||
all_emails.unshift(email: data[:email],
|
||||
verified: !!data[:email_verified])
|
||||
|
||||
# Only consider verified emails to match an existing user. We don't want
|
||||
# someone to be able to create a GitHub account with an unverified email
|
||||
|
@ -106,14 +104,13 @@ class Auth::GithubAuthenticator < Auth::Authenticator
|
|||
)
|
||||
end
|
||||
|
||||
|
||||
def register_middleware(omniauth)
|
||||
omniauth.provider :github,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
setup: lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:client_id] = SiteSetting.github_client_id
|
||||
strategy.options[:client_secret] = SiteSetting.github_client_secret
|
||||
},
|
||||
:scope => "user:email"
|
||||
scope: "user:email"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class Auth::GoogleOAuth2Authenticator < Auth::Authenticator
|
|||
if !result.user && !result.email.blank? && result.email_valid
|
||||
result.user = User.find_by_email(result.email)
|
||||
if result.user
|
||||
::GoogleUserInfo.create({user_id: result.user.id}.merge(google_hash))
|
||||
::GoogleUserInfo.create({ user_id: result.user.id }.merge(google_hash))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Auth::GoogleOAuth2Authenticator < Auth::Authenticator
|
|||
|
||||
def after_create_account(user, auth)
|
||||
data = auth[:extra_data]
|
||||
GoogleUserInfo.create({user_id: user.id}.merge(data))
|
||||
GoogleUserInfo.create({ user_id: user.id }.merge(data))
|
||||
if auth[:email_valid].to_s == 'true'
|
||||
EmailToken.confirm(user.email_tokens.first.token)
|
||||
user.set_automatic_groups
|
||||
|
@ -41,8 +41,8 @@ class Auth::GoogleOAuth2Authenticator < Auth::Authenticator
|
|||
# jwt encoding is causing auth to fail in quite a few conditions
|
||||
# skipping
|
||||
omniauth.provider :google_oauth2,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
setup: lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:client_id] = SiteSetting.google_oauth2_client_id
|
||||
strategy.options[:client_secret] = SiteSetting.google_oauth2_client_secret
|
||||
},
|
||||
|
|
|
@ -39,8 +39,8 @@ class Auth::InstagramAuthenticator < Auth::Authenticator
|
|||
|
||||
def register_middleware(omniauth)
|
||||
omniauth.provider :instagram,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
setup: lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:client_id] = SiteSetting.instagram_consumer_key
|
||||
strategy.options[:client_secret] = SiteSetting.instagram_consumer_secret
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ class Auth::OAuth2Authenticator < Auth::Authenticator
|
|||
end
|
||||
|
||||
# only option at the moment is :trusted
|
||||
def initialize(name, opts={})
|
||||
def initialize(name, opts = {})
|
||||
@name = name
|
||||
@opts = opts
|
||||
end
|
||||
|
|
|
@ -49,15 +49,14 @@ class Auth::OpenIdAuthenticator < Auth::Authenticator
|
|||
)
|
||||
end
|
||||
|
||||
|
||||
def register_middleware(omniauth)
|
||||
omniauth.provider :open_id,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
setup: lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:store] = OpenID::Store::Redis.new($redis)
|
||||
},
|
||||
:name => name,
|
||||
:identifier => identifier,
|
||||
:require => "omniauth-openid"
|
||||
name: name,
|
||||
identifier: identifier,
|
||||
require: "omniauth-openid"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,8 +35,8 @@ class Auth::Result
|
|||
if user.suspended?
|
||||
{
|
||||
suspended: true,
|
||||
suspended_message: I18n.t( user.suspend_reason ? "login.suspended_with_reason" : "login.suspended",
|
||||
{date: I18n.l(user.suspended_till, format: :date_only), reason: user.suspend_reason} )
|
||||
suspended_message: I18n.t(user.suspend_reason ? "login.suspended_with_reason" : "login.suspended",
|
||||
date: I18n.l(user.suspended_till, format: :date_only), reason: user.suspend_reason)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -57,8 +57,8 @@ class Auth::TwitterAuthenticator < Auth::Authenticator
|
|||
|
||||
def register_middleware(omniauth)
|
||||
omniauth.provider :twitter,
|
||||
:setup => lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
setup: lambda { |env|
|
||||
strategy = env["omniauth.strategy"]
|
||||
strategy.options[:consumer_key] = SiteSetting.twitter_consumer_key
|
||||
strategy.options[:consumer_secret] = SiteSetting.twitter_consumer_secret
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue