-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from Mehonoshin/admin-create-users
Admin create users
- Loading branch information
Showing
100 changed files
with
1,459 additions
and
981 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
SECRET_TOKEN= | ||
|
||
EMAIL_USER= | ||
EMAIL_PASS= | ||
EMAIL_FROM= | ||
|
||
ROLLBAR_ACCESS_TOKEN= | ||
|
||
NEWRELIC_LICENSE_KEY= | ||
|
||
ROBOKASSA_LOGIN= | ||
ROBOKASSA_SECRET1= | ||
ROBOKASSA_SECRET2= | ||
|
||
WEBMONEY_SECRET= | ||
WEBMONEY_WALLET_WMZ= | ||
WEBMONEY_WALLET_WMR= | ||
|
||
MAILCHIMP_API_KEY= | ||
MAILCHIMP_ALL_CLIENTS_LIST_ID= |
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 +1,13 @@ | ||
SECRET_TOKEN=0e89a81d2e7be3cce9c45d154df16269b5878061c9967c15329adf1490941e613f0b24dd4955b9e0b0e1356180ae8314b879f20150abad78e1ff4bc039a06d75 | ||
SECRET_TOKEN='0e89a81d2e7be3cce9c45d154df16269b5878061c9967c15329adf1490941e613f0b24dd4955b9e0b0e1356180ae8314b879f20150abad78e1ff4bc039a06d75' | ||
DEFAULT_HOST='smartvpn.dev' | ||
EMAIL_FROM='[email protected]' | ||
|
||
ROBOKASSA_LOGIN='login' | ||
ROBOKASSA_SECRET1='password' | ||
ROBOKASSA_SECRET2='password2' | ||
|
||
WEBMONEY_SECRET='secret value' | ||
WEBMONEY_WALLET_WMZ='Z1234567890' | ||
|
||
MAILCHIMP_API_KEY='mailchimp-key' | ||
MAILCHIMP_ALL_CLIENTS_LIST_ID='test' |
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,59 +1,59 @@ | ||
class Admin::ServersController < Admin::BaseController | ||
before_action :load_resource, only: [:show, :edit, :update, :destroy, :generate_config] | ||
# frozen_string_literal: true | ||
|
||
def index | ||
@servers = Server.all | ||
end | ||
class Admin | ||
class ServersController < Admin::BaseController | ||
before_action :load_resource, only: %i[show edit update destroy generate_config] | ||
|
||
def show | ||
end | ||
def index | ||
@servers = Server.all | ||
end | ||
|
||
def new | ||
@server = Server.new | ||
end | ||
def show; end | ||
|
||
def create | ||
@server = Server.new(resource_params) | ||
if @server.save | ||
redirect_to admin_servers_path, notice: "Сервер успешно добавлен" | ||
else | ||
render :new | ||
def new | ||
@server = Server.new | ||
end | ||
end | ||
|
||
def edit | ||
end | ||
def create | ||
@server = Server.new(resource_params) | ||
if @server.save | ||
redirect_to admin_servers_path, notice: t('admin.servers.notices.created') | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def update | ||
if @server.update(resource_params) | ||
redirect_to admin_servers_path, notice: "Сервер успешно обновлен" | ||
else | ||
render :edit | ||
def edit; end | ||
|
||
def update | ||
if @server.update(resource_params) | ||
redirect_to admin_servers_path, notice: t('admin.servers.notices.updated') | ||
else | ||
render :edit | ||
end | ||
end | ||
end | ||
|
||
def destroy | ||
@server.delete | ||
redirect_to admin_servers_path, notice: "Сервер удален" | ||
end | ||
def destroy | ||
@server.delete | ||
redirect_to admin_servers_path, notice: t('admin.servers.notices.destroyed') | ||
end | ||
|
||
def generate_config | ||
builder = ServerConfigBuilder.new(@server) | ||
config_file = builder.generate_config | ||
send_data config_file.to_text, filename: "#{@server.hostname}.ovpn" | ||
end | ||
def generate_config | ||
builder = ServerConfigBuilder.new(server: @server) | ||
config_file = builder.to_text | ||
send_data config_file, filename: "#{@server.hostname}.ovpn" | ||
end | ||
|
||
private | ||
private | ||
|
||
def load_resource | ||
@server = Server.find(params[:id]) | ||
end | ||
def load_resource | ||
@server = Server.find(params[:id]) | ||
end | ||
|
||
def resource_params | ||
params.require(:server).permit(:hostname, :ip_address, :state, | ||
:config, :protocol, :port, :country_code, | ||
plan_ids: [] | ||
) | ||
def resource_params | ||
params.require(:server).permit(:hostname, :ip_address, :state, | ||
:config, :protocol, :port, :country_code, | ||
plan_ids: []) | ||
end | ||
end | ||
end | ||
|
Oops, something went wrong.