diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 7e41d51..b0f9383 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -18,16 +18,15 @@ } } -.bg-mountains-fixed { +.bg-mountains { background-color: #0C2866; background-size: 1800px auto; background-repeat: no-repeat; background-position: 50% 0%; - background-attachment: fixed; } @media screen and (min-width: 1800px) { - .bg-mountains-fixed { + .bg-mountains { background-size: 100% auto; } } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9be5702..0dea441 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,12 +8,10 @@ def set_current_user end def require_authentication - set_current_user - redirect_to root_path, alert: "Please sign in first." unless Current.user + redirect_to root_path, alert: "Please log in first." unless Current.user end def require_admin - require_authentication redirect_to root_path, alert: "Not authorized." unless Current.admin? end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index d0d2429..c15c6a5 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,9 +1,9 @@ class SessionsController < ApplicationController def create auth = request.env["omniauth.auth"] - user = User.find_or_create_from_omniauth(auth) + user = User.find_or_create_from_omniauth!(auth) session[:user_id] = user.id - redirect_to root_path, notice: "Signed in!" + redirect_to root_path, notice: "Logged in!" end def destroy diff --git a/app/models/user.rb b/app/models/user.rb index 032a7dc..8f3819b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,15 +2,12 @@ class User < ApplicationRecord has_one :submission has_many :votes - def self.find_or_create_from_omniauth(auth) - find_or_create_by(github_uid: auth.uid) do |user| - user.github_username = auth.info.nickname - user.github_email = auth.info.email - end.tap do |user| - user.update( - github_username: auth.info.nickname, - github_email: auth.info.email - ) - end + def self.find_or_create_from_omniauth!(auth) + user = find_or_initialize_by(github_uid: auth.uid) + user.update!( + github_username: auth.info.nickname, + github_email: auth.info.email + ) + user end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1f9de27..10cb454 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -23,16 +23,16 @@ <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %> - -