Compare commits
28 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb4c4e52c4 | ||
|
|
4e3d8c4d57 | ||
|
|
685b28714b | ||
|
|
afe097aac8 | ||
|
|
dd1a5c6f85 | ||
|
|
6849e16491 | ||
|
|
c82d26b905 | ||
|
|
7eca69b4a6 | ||
|
|
e8fb72653d | ||
|
|
2981d737a9 | ||
|
|
c893e37a65 | ||
|
|
f2738686d5 | ||
|
|
359656bdd6 | ||
|
|
be7a275629 | ||
|
|
46f3314738 | ||
|
|
25bd47bf12 | ||
|
|
8861ac7ac0 | ||
|
|
9f5ee2f9db | ||
|
|
93e1dfb923 | ||
|
|
b544201186 | ||
|
|
7c394d03ef | ||
|
|
028007c03a | ||
|
|
2a876d60e6 | ||
|
|
019521dc38 | ||
|
|
1b27ed2f22 | ||
|
|
52b8bf488b | ||
|
|
c546896dc7 | ||
|
|
2eaf740299 |
12 changed files with 33 additions and 1893 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -14,6 +14,7 @@
|
||||||
/test/tmp/
|
/test/tmp/
|
||||||
/test/version_tmp/
|
/test/version_tmp/
|
||||||
/tmp/
|
/tmp/
|
||||||
|
/log/
|
||||||
|
|
||||||
# Used by dotenv library to load environment variables.
|
# Used by dotenv library to load environment variables.
|
||||||
# .env
|
# .env
|
||||||
|
|
|
||||||
2
Capfile
2
Capfile
|
|
@ -10,7 +10,7 @@ require "capistrano/rbenv"
|
||||||
require "capistrano/bundler"
|
require "capistrano/bundler"
|
||||||
|
|
||||||
set :rbenv_type, :user
|
set :rbenv_type, :user
|
||||||
set :rbenv_ruby, '2.4.0'
|
set :rbenv_ruby, '2.6.4'
|
||||||
set :ssh_options, {:forward_agent => true}
|
set :ssh_options, {:forward_agent => true}
|
||||||
# Load the SCM plugin appropriate to your project:
|
# Load the SCM plugin appropriate to your project:
|
||||||
#
|
#
|
||||||
|
|
|
||||||
4
Gemfile
4
Gemfile
|
|
@ -25,10 +25,12 @@ gem 'rack-cors', :require => 'rack/cors'
|
||||||
gem 'fast_jsonapi'
|
gem 'fast_jsonapi'
|
||||||
gem 'will_paginate'
|
gem 'will_paginate'
|
||||||
gem 'capistrano', '3.10.1'
|
gem 'capistrano', '3.10.1'
|
||||||
gem 'capistrano-rails', '~> 1.2'
|
gem 'capistrano-rails', '~> 1.4'
|
||||||
gem 'capistrano-passenger', '~> 0.2.0'
|
gem 'capistrano-passenger', '~> 0.2.0'
|
||||||
gem 'capistrano-rbenv'
|
gem 'capistrano-rbenv'
|
||||||
gem 'capistrano-bundler'
|
gem 'capistrano-bundler'
|
||||||
|
gem 'ed25519'
|
||||||
|
gem 'bcrypt_pbkdf'
|
||||||
# Use Capistrano for deployment
|
# Use Capistrano for deployment
|
||||||
# gem 'capistrano-rails', group: :development
|
# gem 'capistrano-rails', group: :development
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ GEM
|
||||||
airbrussh (1.3.4)
|
airbrussh (1.3.4)
|
||||||
sshkit (>= 1.6.1, != 1.7.0)
|
sshkit (>= 1.6.1, != 1.7.0)
|
||||||
bcrypt (3.1.13)
|
bcrypt (3.1.13)
|
||||||
|
bcrypt_pbkdf (1.0.1)
|
||||||
bootsnap (1.4.5)
|
bootsnap (1.4.5)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
|
|
@ -82,6 +83,7 @@ GEM
|
||||||
crass (1.0.4)
|
crass (1.0.4)
|
||||||
database_cleaner (1.7.0)
|
database_cleaner (1.7.0)
|
||||||
diff-lcs (1.3)
|
diff-lcs (1.3)
|
||||||
|
ed25519 (1.2.4)
|
||||||
erubi (1.9.0)
|
erubi (1.9.0)
|
||||||
factory_girl (4.9.0)
|
factory_girl (4.9.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
|
@ -206,14 +208,16 @@ PLATFORMS
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bcrypt (~> 3.1.7)
|
bcrypt (~> 3.1.7)
|
||||||
|
bcrypt_pbkdf
|
||||||
bootsnap
|
bootsnap
|
||||||
byebug
|
byebug
|
||||||
capistrano (= 3.10.1)
|
capistrano (= 3.10.1)
|
||||||
capistrano-bundler
|
capistrano-bundler
|
||||||
capistrano-passenger (~> 0.2.0)
|
capistrano-passenger (~> 0.2.0)
|
||||||
capistrano-rails (~> 1.2)
|
capistrano-rails (~> 1.4)
|
||||||
capistrano-rbenv
|
capistrano-rbenv
|
||||||
database_cleaner
|
database_cleaner
|
||||||
|
ed25519
|
||||||
factory_girl_rails (~> 4.0)
|
factory_girl_rails (~> 4.0)
|
||||||
faker
|
faker
|
||||||
fast_jsonapi
|
fast_jsonapi
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@ class AuthenticationController < ApplicationController
|
||||||
auth_token =
|
auth_token =
|
||||||
AuthenticateUser.new(auth_params[:email], auth_params[:password]).call
|
AuthenticateUser.new(auth_params[:email], auth_params[:password]).call
|
||||||
user = User.find_by(email: auth_params[:email])
|
user = User.find_by(email: auth_params[:email])
|
||||||
json_response(auth_token: auth_token, user: user)
|
|
||||||
|
response = user.as_json
|
||||||
|
response[:auth_token] = auth_token
|
||||||
|
json_response(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@ class VouchersController < ApplicationController
|
||||||
# GET /vouchers
|
# GET /vouchers
|
||||||
def index
|
def index
|
||||||
@vouchers = Voucher.all
|
@vouchers = Voucher.all
|
||||||
|
whitelist = `mc-whitelist-users`.gsub("\n", "")
|
||||||
|
|
||||||
render json: @vouchers
|
render json: { :vouchers => @vouchers, :whitelist => whitelist }.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /vouchers/1
|
# GET /vouchers/1
|
||||||
|
|
@ -18,25 +19,22 @@ class VouchersController < ApplicationController
|
||||||
def create
|
def create
|
||||||
# Logic for creating a voucher
|
# Logic for creating a voucher
|
||||||
output = ""
|
output = ""
|
||||||
whitelist = `mcrcon -r -H mine.vereto.net -p #{ENV["MC_RCON_PASS"]} "whitelist list" | sed 's/There are*.*whitelisted players: //g'`.split(", ")
|
whitelist = `mc-whitelist-users`.gsub("\n", "").split(", ")
|
||||||
|
|
||||||
if Voucher.exists?(vouchee: params[:voucher]) && params[:voucher].in?(whitelist)
|
if Voucher.exists?(vouchee: params[:voucher]) && params[:voucher].in?(whitelist)
|
||||||
@voucher = Voucher.new(voucher_params)
|
@voucher = Voucher.new(voucher_params)
|
||||||
|
|
||||||
if @voucher.save
|
if @voucher.save
|
||||||
output = `mcrcon -r -H mine.vereto.net -p #{ENV["MC_RCON_PASS"]} "whitelist add #{params[:vouchee]}"`
|
output = `mc-whitelist-users #{params[:vouchee]}`
|
||||||
render json: output, status: :created, location: @voucher
|
render json: { :message => output }.to_json, status: :created, location: @voucher
|
||||||
else
|
else
|
||||||
render json: @voucher.errors, status: :unprocessable_entity
|
render json: @voucher.errors, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
||||||
render json: "{ Voucher is not valid }" + params[:voucher].in?(whitelist), status: :unprocessable_entity
|
render json: { :message => "Voucher is not valid.", :whitelisted => params[:voucher].in?(whitelist), :exists => Voucher.exists?(vouchee: params[:voucher]), :list => whitelist }.to_json, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# PATCH/PUT /vouchers/1
|
# PATCH/PUT /vouchers/1
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ require "action_controller/railtie"
|
||||||
require "action_mailer/railtie"
|
require "action_mailer/railtie"
|
||||||
require "action_view/railtie"
|
require "action_view/railtie"
|
||||||
require "action_cable/engine"
|
require "action_cable/engine"
|
||||||
# require "sprockets/railtie"
|
require "sprockets/railtie"
|
||||||
# require "rails/test_unit/railtie"
|
# require "rails/test_unit/railtie"
|
||||||
|
|
||||||
# Require the gems listed in Gemfile, including any gems
|
# Require the gems listed in Gemfile, including any gems
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
lock "3.10.1"
|
lock "3.10.1"
|
||||||
|
|
||||||
set :application, "vereto-api"
|
set :application, "vereto-api"
|
||||||
set :repo_url, "git@gogs.vereto.tech:PromoStarr/vereto-api.git"
|
set :repo_url, "https://gitlab.com/spengreb/vereto-api.git"
|
||||||
|
|
||||||
# Default branch is :master
|
# Default branch is :master
|
||||||
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,8 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :users
|
resources :users
|
||||||
|
|
||||||
# ** TO DO ** #
|
resources :user_profiles
|
||||||
# Pls activate again when you've made this more secure
|
post 'login', to: 'authentication#authenticate'
|
||||||
# I dont think its a good idea to send passwords over plaintext
|
post 'register', to: 'users#create'
|
||||||
|
|
||||||
# resources :user_profiles
|
|
||||||
# post 'login', to: 'authentication#authenticate'
|
|
||||||
# post 'register', to: 'users#create'
|
|
||||||
# ** TODO ** #
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
5
db/migrate/20200112200527_add_admin_to_users.rb
Normal file
5
db/migrate/20200112200527_add_admin_to_users.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddAdminToUsers < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :users, :admin, :boolean
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2019_09_27_154659) do
|
ActiveRecord::Schema.define(version: 2020_01_12_200527) do
|
||||||
|
|
||||||
create_table "articles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
create_table "articles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
|
@ -48,6 +48,7 @@ ActiveRecord::Schema.define(version: 2019_09_27_154659) do
|
||||||
t.string "password_digest"
|
t.string "password_digest"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.boolean "admin"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "vouchers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
create_table "vouchers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||||
|
|
|
||||||
1870
log/development.log
1870
log/development.log
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue