-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
785 additions
and
747 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
class Admin::BaseController < ApplicationController | ||
before_action :check_admin | ||
module Admin | ||
class BaseController < ::ApplicationController | ||
before_action :check_admin | ||
|
||
private | ||
def check_admin | ||
redirect_to root_path, flash: { error: t('flash.errors.not_allowed') } if user_signed_in? && !current_user.admin? | ||
private | ||
|
||
def check_admin | ||
redirect_to root_path, flash: { error: t('flash.errors.not_allowed') } if user_signed_in? && !current_user.admin? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
class Admin::UsersController < Admin::BaseController | ||
before_action :set_user, only: [:login_as, :ban, :unban] | ||
before_action :prevent_autoban, only: [:ban, :unban] | ||
module Admin | ||
class UsersController < BaseController | ||
before_action :set_user, only: [:login_as, :ban, :unban] | ||
before_action :prevent_autoban, only: [:ban, :unban] | ||
|
||
def index | ||
@users = User.asc(:name).page params[:page] | ||
end | ||
def index | ||
@users = User.asc(:name).page params[:page] | ||
end | ||
|
||
def login_as | ||
sign_in_and_redirect :user, @user | ||
end | ||
def login_as | ||
sign_in_and_redirect :user, @user | ||
end | ||
|
||
def ban | ||
if @user.update_attributes(banned: true) | ||
redirect_to admin_users_path, flash: { success: t('flash.admin.users.success.ban') } | ||
else | ||
redirect_to admin_users_path, flash: { error: t('flash.admin.users.error.ban') } | ||
def ban | ||
if @user.update_attributes(banned: true) | ||
redirect_to admin_users_path, flash: { success: t('flash.admin.users.success.ban') } | ||
else | ||
redirect_to admin_users_path, flash: { error: t('flash.admin.users.error.ban') } | ||
end | ||
end | ||
end | ||
|
||
def unban | ||
if @user.update_attributes(banned: false) | ||
redirect_to admin_users_path, flash: { success: t('flash.admin.users.success.unban') } | ||
else | ||
redirect_to admin_users_path, flash: { error: t('flash.admin.users.error.unban') } | ||
def unban | ||
if @user.update_attributes(banned: false) | ||
redirect_to admin_users_path, flash: { success: t('flash.admin.users.success.unban') } | ||
else | ||
redirect_to admin_users_path, flash: { error: t('flash.admin.users.error.unban') } | ||
end | ||
end | ||
end | ||
|
||
private | ||
def set_user | ||
@user = User.find params[:id] | ||
end | ||
private | ||
|
||
def prevent_autoban | ||
redirect_to admin_users_path, flash: { error: t('flash.admin.users.error.ban') } if @user == current_user | ||
def set_user | ||
@user = User.find params[:id] | ||
end | ||
|
||
def prevent_autoban | ||
redirect_to admin_users_path, flash: { error: t('flash.admin.users.error.ban') } if @user == current_user | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
class PagesController < ApplicationController | ||
|
||
skip_before_action :authenticate_user! | ||
|
||
def home | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
def facebook | ||
if @user = User.from_omniauth(request.env['omniauth.auth']) | ||
sign_in_and_redirect @user, event: :authentication # this will throw if @user is not activated | ||
else | ||
redirect_to root_path, flash: { error: t(APP_CONFIG.facebook.restricted_group_id ? 'flash.sessions.error.restricted' : 'flash.sessions.error.create') } | ||
module Users | ||
class OmniauthCallbacksController < ::Devise::OmniauthCallbacksController | ||
def facebook | ||
@user = User.from_omniauth(request.env['omniauth.auth']) | ||
if @user | ||
sign_in_and_redirect @user, event: :authentication | ||
else | ||
redirect_to root_path, flash: { error: t(APP_CONFIG.facebook.restricted_group_id ? 'flash.sessions.error.restricted' : 'flash.sessions.error.create') } | ||
end | ||
end | ||
end | ||
|
||
protected | ||
def after_omniauth_failure_path_for(scope) | ||
root_path | ||
protected | ||
|
||
def after_omniauth_failure_path_for(_scope) | ||
root_path | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.