Commit c41b74dc authored by jz143's avatar jz143

require login to see apps

parent 84652dbd
...@@ -12,8 +12,12 @@ class ApplicationController < ActionController::Base ...@@ -12,8 +12,12 @@ class ApplicationController < ActionController::Base
private private
def user_not_authorized def user_not_authorized
flash[:alert] = "You are not authorized to perform this action." if current_user.nil?
redirect_to(request.referrer || root_path) redirect_to('/auth/duke_oauth2?' + {origin: request.fullpath}.to_query)
else
flash[:alert] = "You are not authorized to perform this action."
redirect_to(request.referrer || root_path)
end
end end
end end
...@@ -43,7 +43,7 @@ class SessionsController < ApplicationController ...@@ -43,7 +43,7 @@ class SessionsController < ApplicationController
user = User.find_or_create_by_netid(auth_hash.info.netid) user = User.find_or_create_by_netid(auth_hash.info.netid)
session[:user_id] = user.id session[:user_id] = user.id
redirect_to :root, notice: 'Welcome!' redirect_to(request.env['omniauth.origin'] || :root, notice: 'Welcome!')
end end
protected protected
......
...@@ -11,7 +11,7 @@ class AppPolicy < ApplicationPolicy ...@@ -11,7 +11,7 @@ class AppPolicy < ApplicationPolicy
end end
def show? def show?
true user
end end
def create? def create?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment