Skip to content

Commit

Permalink
become path
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Aug 11, 2023
1 parent bfe624c commit cfde18c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@ class ApplicationController < ActionController::Base
ActiveStorage::Current.url_options = { protocol: request.protocol, host: request.host, port: request.port }
#ActiveStorage::Current.url_options = { protocol: "http://", host: "localhost", port: "3000" }
end

def become
if current_user.is_admin?
user = User.find(params[:id])
sign_in(:user, user)
else
redirect_to root_url, error: "not allowed"
end
end

end
6 changes: 3 additions & 3 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ def mine

@tab = params[:tab] || "all"
case @tab
when "all"
@posts = current_user.posts
when "published"
@posts = current_user.posts.published
else "draft"
when "draft"
@posts = current_user.posts.draft
else
@posts = current_user.posts
end

@posts.page(params[:page]).per(10)
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

get "/oembed/", to: "oembed#show", as: :oembed

get "/become/:id", to: "application#become"

get "/embed/:track_id", to: "embeds#show"
get "/oembed/:track_id", to: "embeds#oembed_show", as: :oembed_show
get "/oembed/:track_id/private", to: "embeds#oembed_private_show"
Expand Down

0 comments on commit cfde18c

Please sign in to comment.