diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4c854ea..f6d9a71 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,6 +6,8 @@ class UsersController < ApplicationController before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions] + caches_action :show, expires_in: 10.seconds, layout: false + def index role = Role.find_by(name: params[:role]) badge = Badge.find_by(name: params[:badge]) @@ -16,6 +18,12 @@ class UsersController < ApplicationController end def show + begin + @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"].tr("-", "") == @user.uuid} + rescue + flash.now[:alert] = "An error occured while checking if this user is banned from the server!" + @ban_json = nil + end end # SIGNUP diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 794d2e2..a982928 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -15,11 +15,13 @@

<%= @user.name %>

- - <% if @user.banned? %> - This user is banned! + <% if @ban_json %> + This user is banned on the server for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> <% end %> - + <% if @user.banned? %> + This user is banned on the website! + <% end %> +
<% if !@user.confirmed? %> <% if @user.is?(current_user) || mod? %> Please confirm your email <%= @user.email %> !